0% found this document useful (0 votes)
1 views

Linux_Command_Cheat_Sheet

Linux Cheat sheet

Uploaded by

wosecal309
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

Linux_Command_Cheat_Sheet

Linux Cheat sheet

Uploaded by

wosecal309
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Linux Command Cheat Sheet

File & Directory Management

- pwd: Show current directory


Example: pwd

- ls: List files in a directory


Example: ls -lah

- cd <dir>: Change directory


Example: cd /var/logs

- mkdir <dir>: Create a new directory


Example: mkdir new_folder

- rmdir <dir>: Remove an empty directory


Example: rmdir old_folder

- rm <file>: Remove a file


Example: rm file.txt

- rm -rf <dir>: Remove a folder and its contents


Example: rm -rf my_folder

- cp <source> <dest>: Copy files or folders


Example: cp file1.txt file2.txt

- mv <old> <new>: Move or rename a file


Example: mv old.txt new.txt

File Content & Processing

- cat <file>: Show file contents


Example: cat notes.txt

- less <file>: View file page by page


Example: less largefile.log

- head -n <num> <file>: Show first N lines


Example: head -10 file.txt

- tail -n <num> <file>: Show last N lines


Example: tail -5 logs.txt

- grep '<word>' <file>: Search for a word in a file


Example: grep 'error' syslog.log

- find <dir> -name '<pattern>': Find a file


Example: find /home -name '*.log'

- wc -l <file>: Count lines in a file


Example: wc -l document.txt

Networking & HTTP Requests

- ping <host>: Test connectivity


Example: ping google.com

- traceroute <host>: Show route to a server


Example: traceroute amazon.com

- curl <URL>: Fetch a web page or API response


Example: curl https://example.com

- wget <URL>: Download a file


Example: wget http://example.com/file.zip

- netstat -tulnp: Show all open ports


Example: netstat -tulnp

- nslookup <domain>: Get DNS info


Example: nslookup google.com

- dig <domain>: Perform detailed DNS lookup


Example: dig amazon.com

System Monitoring & Processes

- ps aux: Show running processes


Example: ps aux | grep apache

- top: Show real-time system usage


Example: top

- kill <PID>: Kill a process by ID


Example: kill 1234

- df -h: Show disk usage


Example: df -h

- du -sh <dir>: Show size of a directory


Example: du -sh /var/logs

Permissions & User Management

- chmod 755 <file>: Change file permissions


Example: chmod 755 script.sh
- chown user:group <file>: Change file ownership
Example: chown root:root file.txt

- whoami: Show current user


Example: whoami

- sudo <command>: Run a command as root


Example: sudo apt update

- useradd <user>: Create a new user


Example: useradd pawan

- passwd <user>: Change user password


Example: passwd pawan

You might also like