====== Linux Cheatsheet ======
===== Files and Navigation =====
^ Command ^ Description ^
| ''ls'' | list all files/folders on current dir |
| ''ls -l'' | formatted listing |
| ''ls -la'' | formatted listing including hidden files |
| ''cd
'' | change directory to dir |
| ''cd ..'' | change to parent directory |
| ''cd ./'' | change to dir in parent directory |
| ''cd'' | change to home directory |
| ''pwd'' | show current directory |
| ''mkdir '' | create a directory dir |
| ''rm '' | remove file |
| ''rm -f '' | force remove file |
| ''rm -r '' | remove directory dir |
| ''rm -rf '' | force remove directory dir |
| ''rm -rf /'' | It's like exploding a nuclear bomb targeting your entire operating system. NEVER USE IT! |
| ''cp '' | copy file1 to file2 |
| ''mv '' | mv file1 to file2 |
| ''mv '' | mv file1 to dir as file2 |
| ''touch '' | create or update file |
| ''cat '' | output contents of file |
| ''cat > '' | write standard input into file |
| ''cat >> '' | append standard input into file |
| ''tail -f '' | output contents of file as it grows |
===== Processes =====
^ Command ^ Description ^
| ''ps'' | display currently active processes |
| ''ps aux'' | detailed outputs |
| ''kill pid'' | kill process with process id (pid) |
| ''killall proc'' | kill all processes named proc |
===== System Info =====
^ Command ^ Description ^
| ''date'' | show current date/time |
| ''uptime'' | show uptime |
| ''whoami'' | show you are logged in as |
| ''w'' | display who is online |
| ''cat /proc/cpuinfo'' | display cpu info |
| ''cat /proc/meminfo'' | display memory info |
| ''free'' | show memory and swap usage |
| ''du'' | show directory space usage |
| ''du -sh'' | display readable sizes in GB |
| ''df'' | show disk usage |
| ''uname -a'' | show kernel config |
===== Networking =====
^ Command ^ Description ^
| ''ping host'' | ping host |
| ''whois domain'' | get whois for domain |
| ''dig domain'' | get DNS for domain |
| ''dig -x host'' | reserve lookup host |
| ''wget '' | download file |
| ''wget -c '' | continue stopped download |
| ''wget -r '' | recursively download file from url |
| ''curl '' | output the webpage from url |
| ''curl -o page.html url'' | writes the page to page.html |
| ''ssh -p port user@host'' | connect using port |
| ''ssh -D user@host'' | connect and use bind port |
===== Permissions =====
^ Command ^ Description ^
| ''chmod'' | change permission of file |
* 4 -> read ''r''
* 2 -> write ''w''
* 1 -> execute ''x''
**order**: owner/group/world -> ''-rwxrwxrwx''
Example:
* ''chmod 777'' rwx for everyone
* ''chmod 755'' rwx for owner, rx for group and world