The Linux Command Line, Gently
ten commands that cover most of what you need to start
Security tools, servers and most of the cloud run Linux, and the command line is how you drive them. It looks unfriendly at first, but a small set of commands carries you a long way.
Finding your way around
pwdshows where you are.ls -lalists files, including hidden ones, with permissions and owners.cd foldermoves into a folder;cd ..goes up one level.cat fileprints a file.less filelets you page through a long one.
Searching and filtering
grep "text" fileshows lines that contain text.grep -r "text" foldersearches a whole folder.find / -name "*.log" 2>/dev/nullfinds files by name.headandtailshow the start or end of a file.tail -f filefollows a log as it grows.- The pipe
|sends the output of one command into the next, which is the secret to the command line. For example:grep "Failed password" /var/log/auth.log | wc -lcounts failed logins.
Permissions
ls -l shows something like -rwxr-xr--. The three groups are owner, group and everyone else, each with read (r), write (w) and execute (x). chmod changes them and chown changes the owner. Files that anyone can write to, or programs that run with elevated rights (sudo, the setuid bit), are classic places for privilege escalation.
Seeing the system
ps auxlists processes.topshows what is using resources.ss -tulpnshows listening ports and which program owns them.ip ashows network interfaces and addresses.whoamiandidshow which user you are.
Be careful
Commands run with the power of the account you use. Do not paste commands you do not understand, be extra careful with sudo and rm, and practice in a safe virtual machine or a learning site, not on a machine you care about.[2]
Sources
Test yourself
My notes
Private — saved only on this device, never sent anywhere.