Linux

Table of Contents

1. Change Directory

Use case: cd <directory>
Example: To change to the “Downloads” directory

cd Downloads

2. List Files

Use case: ls [options] [directory]
Example: To list files with detailed information

ls -l

3. Copy Files

Use case: cp [options] source destination
Example: To copy a file to another directory

cp file.txt /path/to/destination/

4. Move/Rename Files

Use case: mv [options] source destination
Example: To move a file to another directory

mv file.txt /path/to/destination/

5. Remove Files/Directories

Use case: rm [options] file/directory
Example: To remove a file

rm file.txt

6. Create Directory

Use case: mkdir [options] directory
Example: To create a directory named “new_folder”

mkdir new_folder

7. Find Files

Use case: find [directory] -name [filename]
Example: To find all .txt files in the current directory

find . -name "*.txt"

8. View File Content

Use case: cat [filename]
Example: To display the content of a file

cat file.txt

9. Edit Text Files

Use case: nano [filename]
Example: To edit a file using nano

nano file.txt

10. Check System Resources

Use case: top
Example: To view and manage running processes

top

11. Network Diagnostics

Use case: netstat [options]
Example: To display all active network connections

netstat -a

12. Firewall Configuration

Use case: ufw [options]
Example: To enable the firewall

ufw enable

13. User Management

Use case: useradd [options] username
Example: To add a new user named “john”

useradd john

14. Change User Password

Use case: passwd [username]
Example: To change the password for the user “john”

passwd john

15. File Permissions

Use case: chmod [options] permissions file
Example: To give read and write permissions to a file

chmod +rw file.txt

16. Archive and Compress Files

Use case: tar [options] archive_name files/directories
Example: To create a compressed archive named “backup.tar.gz” of the “Documents” directory

tar -czvf backup.tar.gz Documents/

17. Search Text in Files

Use case: grep [options] pattern file(s)
Example: To search for the word “error” in all .log files

grep "error" *.log

18. Secure Copy

Use case: scp [options] source destination
Example: To copy a local file to a remote server

scp file.txt user@remote:/path/to/destination/

19. Process Monitoring

Use case: ps [options]
Example: To display information about all processes

ps aux

20. System Information

Use case: uname [options]
Example: To display the system name and version

uname -a

21. Network Packet Capture

Use case: tcpdump [options] [expression]
Example: To capture packets on interface eth0

tcpdump -i eth0

22. File System Encryption

Use case: cryptsetup [options] command
Example: To create an encrypted volume

cryptsetup luksFormat /dev/sdb1

23. Process Priority

Use case: nice [options] command
Example: To run a command with a lower priority

nice -n 10 command

24. File Integrity Checking

Use case: sha256sum [options] file(s)
Example: To calculate the SHA256 hash of a file

sha256sum file.txt

25. SSH Key Authentication

Use case: ssh-keygen [options]
Example: To generate an SSH key pair

ssh-keygen -t rsa -b 2048

26. File System Quotas

Use case: quota [options]
Example: To display disk quotas for the current user

quota -v

27. Secure File Deletion

Use case: shred [options] file(s)
Example: To securely delete a file

shred -u file.txt

28. Disk Usage

Use case: du [options] [directory]
Example: To display disk usage for the current directory

du -h

29. File System Check

Use case: fsck [options] [filesystem]
Example: To check and repair the root file system

fsck /

30. Check Open Ports

Use case: nmap [options] target
Example: To scan open ports on a target

nmap -p 1-1000 target

31. Disk Partitioning

Use case: fdisk [options] device
Example: To create a new partition on /dev/sdb

fdisk /dev/sdb

32. File and Directory Permissions

Use case: chown [options] owner:group file(s)
Example: To change the owner of a file to user “john”

chown john: file.txt

33. Monitor Network Connections

Use case: iftop
Example: To monitor network connections in real-time

iftop

34. File Encryption

Use case: gpg [options] file
Example: To encrypt a file with GPG

gpg -c file.txt

35. File System Mounting

Use case: mount [options] device directory
Example: To mount a USB drive to /mnt/usb

mount /dev/sdc1 /mnt/usb

36. System Log Inspection

Use case: journalctl [options]
Example: To view system logs

journalctl

37. Network Interface Configuration

Use case: ifconfig [interface] [options]
Example: To display network interfaces

ifconfig

38. Process Killing

Use case: kill [options] PID
Example: To kill a process with PID 1234

kill 1234

39. System Resource Monitoring

Use case: htop
Example: To interactively view and manage system processes

htop

40. IP Configuration

Use case: ip [options] [object]
Example: To display IP addresses and routing information

ip address show

41. Disk Formatting

Use case: mkfs [options] device
Example: To create an ext4 file system on /dev/sdb1

mkfs.ext4 /dev/sdb1

42. Network Packet Analysis

Use case: wireshark [options] [filename]
Example: To capture and analyze network packets

wireshark

43. Secure Shell Configuration

Use case: sudo nano /etc/ssh/sshd_config
Example: To edit the SSH server configuration file

sudo nano /etc/ssh/sshd_config

44. User Activity Monitoring

Use case: last [options] [username]
Example: To display last logged-in users

last

45. Memory Usage

Use case: free [options]
Example: To display memory usage statistics

free -m

46. Checksum Verification

Use case: md5sum [options] file(s)
Example: To calculate the MD5 hash of a file

md5sum file.txt

47. System Update

Use case: sudo apt update && sudo apt upgrade
Example: To update the package list and upgrade installed packages

sudo apt update && sudo apt upgrade

48. Check System Uptime

Use case: uptime
Example: To display system uptime

uptime

49. Remote File Editing

Use case: vim [filename]
Example: To edit a file using vim

vim file.txt

50. System Shutdown

Use case: sudo shutdown [options] [time]
Example: To shutdown the system immediately

sudo shutdown now