Linux Checklist
Linux Beginner
File System Hierarchy
/(aka root)/binand/sbin/opt/usr/var/home/etc/proc-
/tmp - Test
- What is ‘/’?
- What is stored in ‘/bin’? what about
/etc? - What ‘/home’ is usually used for?
- What type of files can you find in ‘/var’?
- What is unique about
/tmp?
Navigation
- Commands
pwd- where am I?cd- change directory
-
relative vs. absolute paths
- Test
- How to check your current path?
- Where
cd ..will take you? - What would be the effect of running
cd .? - What will happen when running ‘cd -‘?
Files
- Types of files
- Regular
- Directory
- Socket
- Character Device
- Block Device
- Link
- Named Pipe
- Commands
ls- list files and directories-afor listing hidden files-lfor list formt-torder by time-Fbetter distinguish between regular files and directories
touch- creating files (original intention is updating timestamp)- nice to know:
touch file{1..5}
- nice to know:
rm- remove files-rfor recursive-fto force removal, no questions asked
mkdir- create directories-p- for creating multiple nested directories
rmdir- remove directoriescat- concatenate files (common usage: read a file)mv- move files directories (also rename files and directories)cp- copy a file-rfor recursive (copy a directory)
less- display files on a page-by-page basis
- Test
- How to list hidden files?
- How to create an empty new file?
- How to remove a directory?
- How to rename a file?
- How to copy an entire directory with all its files?
Pattern Matching
This also known as File Globbing
- Patterns
*- matches zero or more of any character?- matches one of any character
Commands
man- manual for commandswhich- get full path for given commandwhatis- one-line manual page descriptionswhereis- locate the binary, source, and manual page files for a commandhistory- command history list- use ![number line] to execute a command from the list
Shell & Terminal
- Terminal
clear- clear the terminal screen (ctrl+l can be also used)ctrl+r- history search of commandsexit(orlogout) - terminate a process, quit the shell
- Shell
env- see your environment variables$HOMR- your home directory$USER- your username$PATH- list of paths where your OS searches for commands you run
echo- display a line of textalias- define or display command shortcuts/aliases
Distributions
- Popular distributions
- Fedora
- Ubuntu
- RHEL, CentOS
- Mint
- Debian
- Arch Linux
- openSUSE
- Test
- What is a distribution?
I/O redirection and manipulation
- File Descriptor
- stdin 0 (standard input) <
- stdout 1 (standard output) >
- stderr 2 (standard error) 2>
-
Append »
- Pipe
- For example:
cat file | wc -lto count number of lines
- For example:
- Commands
- ‘tr’ - translating characters
echo "hello" | tr h Hfor example
tee- writing output to two different streams
- ‘tr’ - translating characters
- Test
- How to redirect output?
- What would be the result of the following command
blop 2> file?
Text Editor
Learning how to use one of them is more than enough
- vim
ito start typing:wqto exit (orshit+zz)
- nano
- emacs
- atom
-
sublime
- Test (mainly for vim)
- How to remove an entire line?
- How to copy 5 lines?
- How to jump to the end of the line
- How to remove one word
- How to jump to the end of the file
Users
- Types of users
- regular
- root
- Commands
useradd- add usersusermod- modify usersuserdel- delete userswho- show who is logged onpasswd- changing passwordlastlog- recent login of userssu- substitute users (in other words, switch to another user)
- Files
/etc/passwd- stores users information/etc/shadow- hashed passwords/etc/group- group
- Test
- how to add a new user?
- should you be using your user or root?
Permissions
- File Permissions
rfor readable (2^2=4)wfor writeable (2^1=2)xfor executable (2^0=1)
- Commands
chmod- modify permissionschmod u+x file- grant execute permissions to owner of the filechmod +x file- grant execute permissions to everyonechmod 444 file- grant read permissions to everyonechmod 600 file- grant read and write permissions to owner of the file
chown- change user ownership of the filechgrp- change group ownership of the fileumask- get or set file mode creation mask (default permissions in simpler words)
- SUID (Set User ID) - allow users running a program as the user owner
sudo chmod u+s filesudo chmod 4755 file
- SGID (Set Group ID) - allow users running a program as the group owner
sudo chmod g+s filesudo chmod 2555 file
- sudo
sudocommand/etc/sudoersfile
- Sticky Bit - only root or owner can modify and/or delete files
- It’s set on /tmp
sudo chmod +t directorysudo chmod 1755 directory
Linux Intermediate
Linux Network
- Commands
ping- test the reachability of a host-cfor number of packets
ip- manage routing, network devices, interfaces and tunnelsip afor interfacesip rfor routingip neighfor any ARP related operation
ethtool- query and manipulate driver and hardware settings-pfor interface led blinking-tfor running tests to check your network interface-Sfor getting statistics
arp- manipulate the system ARP cachedhclient- DHCP clientnetstat- display network connections-nfor IP addresses instead of hostnames-tto show only TCP connections-pto show the PID of the program-lto show only listening sockets
lsof- list open files-ifor sockets
traceroute- print the route packets trace to network hostmtr- network diagnostic tool (traceroute + ping)
- Files
/proc/net/dev- network interfaces list/pro/net/arp- ARP table/etc/sysconfig/network-scripts/*- network configuration files in RHEL based OSs/etc/network/interfaces- network configuration files in Ubuntu
- Types of interfaces
- Regular
- Dummy
- Virtual IP
- Veth
- Bonding
- Modes
- How to activate
- Network Namespaces
ip netnsip netns addfor adding namespacesip netns listfor listing namespacesip netns delfor removing namespacesip netns execfor executing commands inside a network namespace
- Network Kernel Parameters
sysctl net.*/proc/sys/net/*
- Packet Sniffers (one is enough)
tcpdumpwiresharkdhcpdumphttpry
- Test
- How to list the interfaces in your system?
- How to display the routing table?
- How to change the MTU of an interface?
Debugging & Troubleshooting
- CPU and Memory
top- processes memory and cpu consumptionfree- amount of free and used memory-gfor the amount of memory in gigabytes
vmstat- virtual memory statisticshtop- interactive process vieweratop- system and process monitor/proc/meminfo
- Network Commands
netstat- network connectionstraceroute- network connectionsIPTraf- IP LAN monitoringiftop- network bandwidth monitoring
- Disk and Filesystem
iotop- I/O monitoriostat- I/O statistics for devices and partitions
Processes
- States
- Running
- Waiting
- Stopped
- Zombie
- Commands
ps- process statuskill [pid]- terminate processespkill- terminate processes based on names and other attributions
- Files
/proc/[PID]
- Running in the background
- For example:
my_program &
- For example:
- Signals
- Types
SIGTERM- default signal to terminate a process gracefullySIGKILL- terminate process “brutally” (kill -9)SIGHUP- mostly used for reloading configuration of a process/service
- Commands
trap- “catch” a signal
- Types
Archives
- Commands
- tar
- gzip
- zip
- unzip
- Test
- How to create an archive?
- How to extract the content of an archive?
Files & Output - Intermediate level
- Commands
find- search for filessort- sort, merge, or sequence check text fileswc- count lines, words, …grep- search files for characters that match a certain pattern-Rfor recursive search in all files under a certain directory-ifor ignoring case sensitive
nl- line numberinguniq- remove duplicatesjoin- join multiple files togethersplit- split one file into multiple different files
Storage & Filesystem
-
inode
- Links
- soft link
- hard link
- Commands
file- determine file typestat- file or file system statusdu- file space usagedf- disk usage of the file systemmount- mount filesystems
- LVM
- pv
- vg
- lv
- Test
- Can you create soft links between different file systems? what about hard links?
- What information inode stores?
Linux Advanced
Hardware
- Commands
lshw- list hardwarelspci- list all PCI devicesdmidecode- DMI table decoder
System Calls
openreadexeccloneforkvfork
Comments