cmd > file # stdout to file (overwrite)cmd >> file # stdout to file (append)cmd 2> file # stderr to filecmd > file 2>&1 # stdout and stderr to the same filecmd < file # file as stdincmd1 | cmd2 # stdout of cmd1 -> stdin of cmd2
4. Processes
ps x # all your processesps ax # all processes on the systemps u # more detailed informationps w # full command namesps u $$ # info about the current shell ($$ = its PID)
Character device (data as a stream, e.g. terminals)
/dev/tty, /dev/null
p
Named pipe (FIFO) — one process writes, another reads
mkfifo mypipe
s
Socket — local inter-process communication
/run/docker.sock
chmod — numeric values
Permission
Value
r read
4
w write
2
x execute
1
none
0
Example 754: owner rwx = 7, group r-x = 5, others r-- = 4.
umask — default permissions mask for newly created files
Links: hard vs symbolic
ln <target> <linkname> # hard linkln -s <target> <linkname> # symbolic (soft) link
The difference is what the link points to. A hard link is another name for the same inode — the actual data on disk. A symbolic link is a separate small file that stores the path of the target.
Hard link
Symbolic link
Points to
Inode (the data itself)
Path name of the target
ls -l shows
Regular file (-), link count > 1
l, e.g. link -> target
Target deleted
Data survives as long as one name remains
Link breaks (“dangling”)
Target moved/renamed
Still works
Breaks
Across filesystems
No (same filesystem only)
Yes
Link to a directory
No
Yes
Own permissions
Same as the file (it is the file)
Ignored — target’s permissions apply
Check with ls -li (the -i shows the inode number): hard links to the same file share one inode number, and the second column is the link count.
6. Archives and compression
gzip file # -> file.gzgunzip file.gzzcat file.gz # same as gunzip -dc (print to stdout)tar cvf archive.tar file1 file2 # createtar xvf archive.tar # extracttar tvf archive.tar # list contentstar ztvf file.tar.gz # list a gzipped archive
Flag
Meaning
c
create
x
extract
t
test / list
v
verbose
f
next argument is the file
p
preserve permissions
z
gzip compression
7. Filesystem Hierarchy Standard
/├── bin/ ready-to-run commands (essential binaries)├── sbin/ system executables (for root)├── boot/ kernel and boot loader files├── dev/ device files├── etc/ core system configuration (passwd, boot, network, ...)├── home/ personal directories of regular users├── lib/ shared and static libraries used by executables├── media/ mount point for removable media (USB drives, ...)├── opt/ additional third-party software├── proc/ info about running processes and kernel parameters├── run/ runtime data: PIDs, sockets, status records, logging├── sys/ device and system interface (similar to /proc)├── tmp/ small temporary files├── var/ variable data: logs, caches, user tracking└── usr/ user programs and data ├── include/ header files for the C compiler ├── local/ software installed by the administrator ├── man/ manual pages └── share/ architecture-independent files
Kernel location: /vmlinuz or /boot/vmlinuz.
8. Root and sudo
sudo <cmd> # run command as rootvisudo # safely edit /etc/sudoers (who may use sudo)journalctl SYSLOG_IDENTIFIER=sudo # view sudo logs