Você está na página 1de 4

Every single file and directory starts from the

root directory.

Only root user has write privilege under this


1. / Root
Directory that contains temporary files created directory.
by system and users.
8. /tmp Temporary Files Please note that /root is root users home
Files under this directory are deleted when directory, which is not same as /.
system is rebooted.
Contains binary executables.
Contains binaries, libraries, documentation,
Common linux commands you need to use in
and source-code for second level programs.
single-user modes are located under this
/usr/bin contains binary files for user 2. /bin User Binaries directory.
programs. If you cant find a user binary
Commands used by all the users of the
under /bin, look under /usr/bin. For example:
system are located here.
at, awk, cc, less, scp
For example: ps, ls, ping, grep, cp.
/usr/sbin contains binary files for system
administrators. If you cant find a system Just like /bin, /sbin also contains binary
9. /usr User Programs
binary under /sbin, look under /usr/sbin. For executables.
example: atd, cron, sshd, useradd, userdel
But, the linux commands located under this
/usr/lib contains libraries for /usr/bin and /usr/ directory are used typically by system
sbin 3. /sbin System Binaries
administrator, for system maintenance
purpose.
/usr/local contains users programs that you
install from source. For example, when you For example: iptables, reboot, fdisk, ifconfig,
install apache from source, it goes under /usr/ swapon
local/apache2
Contains configuration files required by all
Home directories for all users to store their programs.
personal files. 10. /home Home Directories
This also contains startup and shutdown shell
For example: /home/john, /home/nikita 4. /etc Configuration Files
scripts used to start/stop individual programs.
Contains boot loader related files. For example: /etc/resolv.conf, /etc/
logrotate.conf
Kernel initrd, vmlinux, grub files are located
under /boot 11. /boot Boot Loader Files Contains device files.
For example: initrd.img-2.6.32-24-generic, These include terminal devices, usb, or any
vmlinuz-2.6.32-24-generic 5. /dev Device Files
device attached to the system.
Contains library files that supports the Common For example: /dev/tty1, /dev/usbmon0
binaries located under /bin and /sbin Directories
12. /lib System Libraries Contains information about system process.
Library filenames are either ld* or lib*.so.*
This is a pseudo filesystem contains
For example: ld-2.11.1.so, libncurses.so.5.7 information about running process. For
example: /proc/{pid} directory contains
opt stands for optional.
6. /proc Process Information information about the process with that
Contains add-on applications from individual particular pid.
vendors. 13. /opt Optional add-on Applications
This is a virtual filesystem with text
add-on applications should be installed under information about system resources. For
either /opt/ or /opt/ sub-directory. example: /proc/uptime

Temporary mount directory where sysadmins Is an interface to the kernel. Specifically, it


14. /mnt Mount Directory provides a filesystem-like view of information
can mount filesystems.
and configuration settings that the kernel
Temporary mount directory for removable provides, much like /proc.
devices. 6.5. /sys - Kernel Subsystems Info
Writing to these files may or may not write to
For examples, /media/cdrom for CD-ROM; / 15. /media Removable Media Devices the actual device, depending on the setting
media/floppy for floppy drives; /media/ you're changing. It isn't only for managing
cdrecorder for CD writer devices, though that's a common use case.

srv stands for service. var stands for variable files.

Contains server specific services related data. Content of the files that are expected to grow
16. /srv Service Data
can be found under this directory.
For example, /srv/cvs contains CVS related
data. 7. /var Variable Files This includes system log files (/var/log);
packages and database files (/var/lib); emails
(/var/mail); print queues (/var/spool); lock files
(/var/lock); temp files needed across reboots
(/var/tmp);
CentOS Is non-volatile firmware used to perform hardware initialization during the booting process (power-on startup).
RedHat
Fedora Loads a boot loader of an operating system from a mass memory device
Ubuntu A master boot record (MBR) is a special type of boot sector at the
Debian very beginning of partitioned computer mass storage devices like
Mint
fixed disks or removable drives.
Popular
SuSE
The MBR holds the information on how the logical partitions,
Gentoo containing file systems, are organized on that medium.

Slackware

many others Distribution


The MBR also contains executable code to function as a loader for
Boot Loader the installed operating systemusually by passing control over to
the loader's second stage, or in conjunction with each partition's
Kernel volume boot record (VBR). This MBR code is usually referred to as a
boot loader.
Daemons

The Shell Components

Graphical Server BIOS


Allows only for 4 primary partitions
Desktop Environment Master Boot Record (MBR)
Maximum disk size of 4GB
Applications
Boots a Linux system (BIOS comes first)
Is an inter-process communication (IPC) and remote procedure call (RPC)
mechanism that allows communication between multiple computer Runs before the Operating System, but can
programs (that is, processes) concurrently running on the same machine. Booting be configured from the operating system.
dbus Software Bus
Secure and Reliable Presents a choice of operating systems (including,
perhaps, multiple Linux kernels), and loads the
Provides High-Level API selected OS kernel into memory. They let you
Startup pass arguments on to a Linux kernel along the
Replaced ext ext2 Boot Loader way, and can be configured to boot non-Linux
operating systems on the same machine.
Allows Journaling, a technique in computer
Default in most linux systems ext3
file systems to prevent corruption. LILO
Allows huge files and filesystems ext4 Replacement
File Systems Common Bootloaders GRUB Legacy
Replacement
Reziseable journaling filesystem reiserfs GRUB2
btree filesystem. Supports checksums, Stored in the first 446 Bytes.
pooling, snapshots, defragmentation, resizing, btrfs
filesystem checks. Is a specification that defines a software interface between an operating system and
platform firmware. UEFI replaces the Basic Input/Output System (BIOS) firmware
hd refers to an IDE-type drive
Unlike BIOS, UEFI does not rely on a boot sector, defining instead a boot manager
sd refers to a SCSI drive in general, but is as part of the UEFI specification. When a computer is powered on, the boot
mostly popular for SATA drives and CD/DVD manager checks the boot configuration and based on its settings, loads into
memory and then executes the specified OS loader or operating system kernel.
fd is floppy disk
GUID Partition Table (GPT) is a standard for the layout of the partition
/dev/xxyN table on a physical storage device used in a desktop or server PC,
This is the name of the directory in which all device files reside. Since such as a hard disk drive or solid-state drive, using globally unique
partitions reside on hard disks, and hard disks are devices, the files /dev/ UEFI EFI System partition, often abbreviated to identifiers (GUID). Although it forms a part of the Unified Extensible
representing all possible partitions reside in /dev/. ESP, is a data storage device partition that is Firmware Interface (UEFI) standard (Unified EFI Forum proposed
Device Naming System
used in computers adhering to the UEFI replacement for the PC BIOS), it is also used on some BIOS systems
The first two letters of the partition name indicate the type of device on which specification. Accessed by the UEFI firmware because of the limitations of master boot record (MBR) partition tables,
xx which use 32 bits for storing logical block addresses (LBA) and size
the partition resides, usually either hd (for IDE disks) or sd (for SCSI disks). EFI Loader when a computer is powered up, it stores GPT
UEFI applications and the files these information on a traditionally 512-byte disk sector.
This letter indicates which device the partition is on. For example, / applications need to run, including operating
y Hard disk size depends on OS limits
dev/hda (the first IDE hard disk) or /dev/sdb (the second SCSI disk). system kernels. Supported partition table
schemes include MBR and GPT No limit on the number of partitions that can
The final number denotes the partition. The first four (primary or extended) Booting
partitions are numbered 1 through 4. Logical partitions start at 5. So, for be created
N
example, /dev/hda3 is the third primary or extended partition on the first IDE hard
disk, and /dev/sdb6 is the second logical partition on the second SCSI hard disk. Common Bootloaders GRUB2

Creating single logical volumes of multiple physical volumes or In Unix-based computer operating systems, init (short for initialization) is the first process started
entire hard disks (somewhat similar to RAID 0, but more similar to during booting of the computer system. Init is a daemon process that continues running until the
JBOD), allowing for dynamic volume resizing. system is shut down. It is the direct or indirect ancestor of all other processes and automatically
adopts all orphaned processes. Init is started by the kernel using a hard-coded filename; a kernel
Is a device mapper target that provides
Managing large hard disk farms by allowing disks to be added and panic will occur if the kernel is unable to start it. Init is typically assigned process identifier 1.
logical volume management for the
replaced without downtime or service disruption, in combination with Linux kernel. Most modern Linux
hot swapping. Logical Volume Manager (LVM) At boot time, the boot loader loads the kernel and the initramfs image into memory and starts the
distributions are LVM-aware to the point kernel. The kernel checks for the presence of the initramfs and, if found, mounts it as / and runs /init.
On small systems (like a desktop), instead of having to estimate at of being able to have their root file The init program is typically a shell script. Note that the boot process takes longer, possibly
installation time how big a partition might need to be, LVM allows systems on a logical volume. Linux significantly longer, if an initramfs is used.
filesystems to be easily resized as needed.
The /sbin/init program (also called init) coordinates the rest of the boot process and configures the
Performing consistent backups by taking snapshots of the logical volumes. environment for the user. When the init command starts, it becomes the parent or grandparent of all
of the processes that start up automatically on the system.
Is a device manager for the Linux kernel. It handles all user
space events raised when hardware devices are added into Is a suite of basic building blocks for a Linux system. It provides a system
the system or removed from it, including firmware loading and service manager that runs as PID 1 and starts the rest of the system.
as required by certain devices. systemd provides aggressive parallelization capabilities, uses socket and
D-Bus activation for starting services, oers on-demand starting of
On some Linux distributions (e.g. Debian, udev daemons, keeps track of processes using Linux control groups, maintains
Mounted to /tmp
Ubuntu), /tmp is a normal directory Provided by temporary filesystem tmpfs mount and automount points, and implements an elaborate transactional
Device Managers dependency-based service control logic. systemd supports SysV and LSB
/dev/shm uses tmpfs. init scripts and works as a replacement for sysvinit.
Mounted to /dev on startup Is an init system used in Linux distributions to bootstrap the user space.
Subsequently to booting, it is used to manage system processes.
devfsd
It is a replacement for the UNIX System V and Berkeley Software
hotplug
Distribution (BSD) init systems
qmail
consoled
postfix An MTA is an application that routes and
transmits email from one node on a network journald
sendmail to another. MTA - Mail Transfer Agents logind
exim Init
networkd
It uses a protocol known as SMTP (Simple Components
systemd timedated
Mail Transfer Protocol) to perform its task.
udevd

libudev
Systems
systemd-boot

Run Targets

File Permissions File System System /etc/systemd/system


Sticky bit. Prevents
Setuid / Setgid : Run the
folder deletion even if a Chmod a+x filename Package /usr/lib/systemd/system
program as the owner with Scripts
user has write (everyone gets
the owners permission /etc/systemd/system takes precedence over /
permissions execute)
usr/lib/systemd/system

System V - style runlevels

BSD

Is a pseudo file system provided by the Linux kernel that exports


information about various kernel subsystems, hardware devices,
and associated device drivers from the kernel's device model to
user space through virtual files.
sysfs
In addition to providing information about various devices
and kernel subsystems, exported virtual files are also used
for their configuring.
Networking Monitoring Mounted to /sys

Is a special filesystem in Unix-like operating systems that


presents information about processes and other system
information in a hierarchical file-like structure, providing a more
procfs convenient and standardized method for dynamically
accessing process data held in the kernel than traditional
tracing methods or direct access to kernel memory.

Mounted to /proc
You have seen that while you are editing, your last deletion (d
or x) or yank (y) is saved in a buer (a place in stored
memory). You can access the contents of that buer and put
the saved text back in your file with the put command (p or
P).
Buers The vi editor has a total of 27 buers: 26
named buers (az) and 1 unnamed buer
that is overwritten by each new operation.
Delete character to the right of cursor x
Named buers
Delete character to the left of cursor X
The Unnamed buer
Delete to the end of the line D Deleting
Just about any keystroke or action can be
Delete current line dd done X number of times by prefixing it with a
number.
Delete current line :d Force Multipliers
For example, to move the cursor to line 5, you
Yank the current line yy would press 5G. Moving 12 words to the right
Yanking is accomplished with 12W.
Yank the current line :y
vi filename
"/home/rbrunson/file1" 57L, 1756C 18,1 Top
vi +/string filename open a file with a search string
The numbers 18,1 on the right side of the message line are the current Opening
line and column numbers, and the Top text is the current position of the Message line edit a file and have the cursor jump to a
cursor. This changes to be Bot if you entered the last half of the file. The vi +18 /etc/inittab
particular line
other value possible is All, which simply means that all the contents of
the file are currently on the screen. Vi has two modes insertion mode and command mode. The editor
begins in command mode, where the cursor movement and text
Exit, saving changes :x deletion and pasting occur. Insertion mode begins upon entering
Modes an insertion or change command. [ESC] returns the editor to
Exit as long as there have been no changes :q command mode (where you can quit, for example by typing :q!).
Quitting
Exit and save changes if any have been made ZZ Most commands execute as soon as you type them except for
"colon" commands which execute when you press the ruturn key.
Exit and ignore any changes :q!
You can only get to last line mode from
Move left h command mode, and you get into last line
mode by pressing the colon key
Move down j
You can do simple things, like quitting your vi
Move up k LastLine mode
session
Move right l You can also perform some amazing vi search
commands or vim search and replace
Move to next word w commands
Move to next blank delimited word W vi
i Insert before cursor
Move to the beginning of the word b I Insert before line
Move to the beginning of blank delimted word B a Append after cursor
Move to the end of the word e A Append after line
Inserting Text
Move to the end of Blank delimited word E o Open a new line after current line
Move a sentence back ( O Open a new line before current line
Move a sentence forward ) r Replace one character
Move a paragraph back { R Replace many characters
Motion
Move a paragraph forward } You press U in Command mode to undo a
single operation or the latest in a series of
Move to the begining of the line 0
changes. If you opened a file, made 30
Undo Operations
Move to the end of the line $ changes, and then pressed the U key 30
times, you'd end up with the exact same file
Move to the first line of the file 1G you had opened.

Move to the last line of the file G /string Search forward for string

Move to nth line of the file nG ?string Search back for string
Search
Move to nth line of the file :n n Search for next instance of string

Move forward to c fc N Search for previous instance of string

Move back to c Fc :s/pattern/string/flags Replace pattern with string according to flags.

Move to top of screen H g Flag - Replace all occurences of pattern


Replace
Move to middle of screen M c Flag - Confirm replaces.

Move to botton of screen L & Repeat last :s command

Move to associated ( ), { }, [ ] % :w file Write to file

:r file Read file in after line

:n Go to next file
Files
:p Go to previos file

:e file Edit file

!!program Replace line with output from program


. (dot) Any single character except newline
Matches if the line contains the value Hello /Hello/
* zero or more occurances of any character
Matches if the line contains TEST by itself /^TEST$/
[...] Any single character specified in the set
Matches if the line starts with any letter /^[a-zA-Z]/
[^...] Any single character not specified in the set
Matches if the first character of the line is a-z
and there is at least one more of any /^[a-z].*/ ^ Anchor - beginning of the line
character following it $ Anchor - end of line
Matches if line ends with 2134 /2134$/ \< Anchor - beginning of word
Examples Regex(7) Rules
Matches is the line contains 21 or 35 \> Anchor - end of word
Note the use of ( ) with the pipe symbol to /\(21|35\)/
\(...\) Grouping - usually used to group conditions
specify the 'or' condition
\n Contents of nth grouping
Matches if there are zero or more numbers in
/[0-9]*/
the line One or more occurrences of the preceding
+
element
Matches if the first character is not a # in the
/^[^#]/
line Can mean the start and end of a regular
/
expression

Você também pode gostar