Clean, succint and organized for quick reading. Email [email protected] for suggestions and additions.
Networking Hardware – displays network interfaces and up ip addr show dmesg - Detects hardware and boot messages addresses last reboot – System reboot history ip address add – Setups an ip address uptime – System's up time hostname – system hostname lshw – Shows hardware systems configuration info hostname -i – looks up local ip address lsblk – Shows block devices and info whois domain – See whois info for domain lspci -tv – Shows PCI devices ping host – tests connectivity to host and produces output lsusb -tv – Shows USB devices dig – Grabs DNS info from domain lshal – Lists devices and properties dig -x host – Reverse host lookup dmidecode – Shows BIOS hardware info ifconfig – Configures network interfaces hdparm -l /dev/sda – Shows disk info iwconfig – Configures wireless network interfaces hdparm -tT /dev/sda – Speed test on disk host domain – Looks up the DNS ip address for the badblocks -s /dev/sda – Test for unreadable disk blocks specified domain ethtool eth0 – Ethernet status File and Directory mii-tool eth0 – Ethernet status ./ - current directory netstat – Network monitor tool ../ - parent directory iptables -L – Firewall rules ../../ - two parent directories down wget file – Downloads file /* - all files in targeted directory wget -c file – Stops file download Mkfs – Creates filesystem nmap localhost – Scans local host for ports Dd – Clones filesystem traceroute6 ipaddress – Detects network route to target ip Touch – Creates file with timestamp address Cat – Shows file content More – Segments file to navigate content Administration Head – Shows first 10 lines of text print working directory Pwd – Tail – Shows last 10 lines of text Elevates user to administrator access Sudo – Tail -f – Shows Content of new file as it grows Makes a system administrator Sudo -s – Vi – editor Exits current job and terminal Exit – Nano – text editor Cleans files in current directory Clean – Mkdir – creates new directory Change directory Cd – Rmdir – Removes directory Cd - - Change to last directory you were present Cp file other file – copies one file to another Ls – list content of current directory Cp -r dir newdirectory – Copies one directory to new dir Ls -l – view details of content in directory Rm – removes file Ls -a - Shows all content, including hidden files Rm -f – does not ask for permission Ls -R – Lists content recursively Mv file newdir – Moves file to new directory Ls -r – lists content in reverse order Mv dir subdir - Moves directory to new sub-directory Ls -t – Lists by last modified Mv dir newdirname - Renames directory Ls -S – Lists by file size Wc – Prints number of file bytes, words and lines Ls -l – Long listing format Ln -s file link – Creates symbolic link to file Ls -1 – Lists one file per line Ls -m – Lists in comma separated output Ls -Q – Quotes the listed content Man command - Shows manual of command Time command – times the command process length Compression Mount – mounts a filesystem Tar -cf .tar file – Creates compressed archive Cal – terminal calendar Tar -xf – Extracts files from .tar archive Control -c – kills current process Gzip file – Compresses file and renames it Control-insert – Copies text to windows clipboard Gzip -d .giz file - Decompresses file Shift-insert – Pastes copied text to terminal Executing Commands Encryption Cmd1 ; cmd2 – Runs cmd1 and then cmd2 Gpg -o newfile.gpg -c targeted file – Encrypts file Cmd1 && cmd2 – Runs cmd2 if cmd1 is successful Gpg -o newfile -d encryptedfile.gpg – Decrypts file Cmd1 | cmd2 – Pipes output of cmd1 to cmd2 Gpg-zip -o encryptedfile.tgz.gpg -c -s targetedfile - Zips Cmd1 || cmd2 - runs cmd2 if first command is and encrypts directory unsuccessful Cmd & - Runs command in a subshell Command > file – redirects command to write to file Command >> file – Appends output of command to the file File Permissions Date > timestamp - Redirects date command output to Adduser – adds user timestamp file in current directory Usermod – edits user credentials Date >> timestamp – appends date command output to Deluser – deletes user timestamp file Groups – lists group info Groupadd – adds group Groupmod – edits group credentials Delgroup – deletes group Users – lists users Bash Variables Talk – tool for talking between system users Env - environment variables Chmod users=permissions file/directory - changes Echo $NAME - output value of NAME variable file/archive permissions Export NAME=value - Sets NAME to value $PATH - shows executable search path $HOME - home directory Searching Files $SHELL – current shell Locate – searches for files in system index Find /dir -name file name - Finds files starting with name dir Find /dir -user name – finds files owned by name dir Find /dir -mmin num – finds files modified less than the Bash Shortcuts number of minutes ago CTRL-z – sleeps current program Grep pattern files – searches for pattern in files CTRL-a – moves cursor to start of the line Grep -i – case sensitive search CTRL-e – moves cursor to end of the line Grep -r – recursive search CTRL-u – Cuts to start of the line Grep -v – inverted search CTRL-k – Cuts to the end of the line Grep -o – matches part of file only CTRL-r – Searches history !! - Repeats last command Process Management !abc – Runs last command starting with “abc” Pmap – memory map of processes !abc:p – prints last command starting with “abc” Ps – shows snapshot of processes !$ - last argument of previous command Top – Shows real-time processes !* - all arguments of previous command Kill pid – Kills process with set id ^abc^123 – runs previous command replacing “abc” with kills all processes with set name “123” Pkill – Command & - Starts processes in background Nohub command & - Starts processes in background and keeps it running after logging off Installing from Source Killall – kills all processes with set name Make – builds package Make install – builds and installs package System Info Dpkg -i pkg.deb – installs a debian package Uname -a – prints system and kernel inform Rpm -Uvh pkg.rpm – installs an RPM package W – who is online Makepkg - tool for building packages in Arch Linux Head -n1 /etc/issue – Shows distribution info Yoaurt – package manager front-end for building packages Whoami – Shows username in Arch Linux Finger user – user info Cat /proc/cpuinfo – cpu information Cat /proc/meminfo – memory information Df – disk information Du – Directory space usage Free – Memory and swap usage Whereis – applications location Which - Applications run by default