Pages

Sunday, April 21, 2024

100 Essential Commands Every Expert Linux Administrator Should Know

100 Essential Commands Every Expert Linux Administrator Should Know



  1. awk: Text processing and pattern matching.

    • awk '/pattern/ {action}' filename
  2. sed: Stream editing for transforming text.

    • sed -i 's/old/new/g' filename
  3. grep: Searches for patterns in text.

    • grep -P '^a.*z$' filename
  4. tcpdump: Captures and analyzes network packets.

    • tcpdump -i eth0 'port 80'
  5. netstat: Displays network connections, routing tables, and statistics.

    • netstat -tulpn
  6. iptables: Manages Linux firewall rules.

    • iptables -A INPUT -p tcp --dport 80 -j ACCEPT
  7. systemctl: Controls the systemd system and service manager.

    • systemctl status nginx
  8. strace: Traces system calls and signals.

    • strace -c ls
  9. lsof: Lists open files and the processes that opened them.

    • lsof -i :22
  10. rsync: Efficient file copying and synchronization.

    • rsync -avz /src/ /dest/
  11. perf: Performance analyzing tool.

    • perf stat -B dd if=/dev/zero of=/dev/null count=1000000
  12. vmstat: Reports virtual memory statistics.

    • vmstat 1
  13. sar: System activity reporter.

    • sar -u 1 3
  14. ss: Investigates sockets.

    • ss -tulwn
  15. find: Searches for files in a directory hierarchy.

    • find / -type f -name 'config.php' -exec chmod 644 {} \;
  16. nmap: Network exploration and security auditing.

    • nmap -A -T4 target_ip
  17. htop: Interactive process viewer.

    • htop
  18. iostat: Monitors system input/output device loading.

    • iostat -mx 2
  19. dstat: Versatile tool for generating system resource statistics.

    • dstat -cdngy 5 20
  20. iftop: Displays bandwidth usage on an interface.

    • iftop -i eth0
  21. ip: Shows and manipulates routing, devices, policy routing, and tunnels.

    • ip addr show
  22. dig: DNS lookup.

    • dig +trace yourdomain.com
  23. watch: Executes a program periodically, showing output.

    • watch -n 2 'df -h'
  24. crontab: Manages a cron table for scheduling tasks.

    • crontab -e
  25. mdadm: Manages MD (multi-disk) devices for RAID arrays.

    • mdadm --detail /dev/md0
  26. chroot: Changes the root directory.

    • chroot /path/to/new/root
  27. GnuPG: Encrypts and signs data.

    • gpg --encrypt --recipient name@example.com file.txt
  28. traceroute: Traces the route packets take to a network host.

    • traceroute google.com
  29. journalctl: Queries the systemd journal.

    • journalctl -u nginx.service --since yesterday
  30. nmcli: NetworkManager command-line tool.

    • nmcli dev status
  31. firewall-cmd: Manages firewalld settings.

    • firewall-cmd --list-all
  32. bpftrace: Traces Linux kernel using BPF.

    • bpftrace -e 'tracepoint:syscalls:sys_enter_* { @[probe] = count(); }'
  33. fail2ban: IP banning to protect against brute-force attacks.

    • fail2ban-client status sshd
  34. ipset: Creates IP collections for use with iptables.

    • ipset create test hash:ip
  35. iotop: Monitors I/O usage by processes.

    • iotop -o
  36. mtr: Network diagnostic tool.

    • mtr myserver.com
  37. glances: System monitoring tool.

    • glances
  38. ncdu: Disk usage analyzer with an ncurses interface.

    • ncdu /path/to/directory
  39. dd: Convert and copy a file.

    • dd if=/dev/zero of=/dev/sda bs=1M count=1024
  40. fuser: Identify processes using files or sockets.

    • fuser -uv /path/to/file
  41. kdump: Kernel crash dumping mechanism.

    • systemctl status kdump
  42. parted: Disk partitioning and resizing tool.

    • parted -l
  43. lsblk: List information about block devices.

    • lsblk
  44. pv: Monitor the progress of data through a pipeline.

    • pv data.file | gzip > data.file.gz
  45. mount: Mount a filesystem.

    • mount /dev/sda1 /mnt
  46. umount: Unmount file systems.

    • umount /mnt
  47. renice: Alter priority of running processes.

    • renice +10 -p 1234
  48. at: Schedule commands to be executed at a particular time.

    • echo "echo hello" | at now + 1 minute
  49. scp: Secure copy of files over the network.

    • scp localfile user@remote:/path
  50. tar: Archive files into a tape archive (tar) format.

    • tar -czvf archive.tar.gz /path/to/directory
  51. curl: Tool to transfer data from or to a server.

    • curl -O http://example.com/file.zip
  52. wget: Non-interactive network downloader.

    • wget http://example.com/file.zip
  53. ssh: Secure Shell, a protocol for secure remote login and other secure network services.

    • ssh user@host
  54. scp: Secure copy (remote file copy program).

    • scp file.txt user@host:/path
  55. rsnapshot: Local and remote filesystem snapshot utility.

    • rsnapshot daily
  56. vim: Highly configurable text editor.

    • vim filename
  57. nano: Easy-to-use text editor.

    • nano filename
  58. git: Distributed version control system.

    • git clone https://github.com/user/project.git
  59. screen: Full-screen window manager that multiplexes a physical terminal.

    • screen -S session_name
  60. tmux: Terminal multiplexer, lets you switch easily between several programs in one terminal.

    • tmux new -s session_name
  61. ansible: Automation tool for software provisioning, configuration management, and application deployment.

    • ansible all -m ping
  62. terraform: Tool for building, changing, and versioning infrastructure safely and efficiently.

    • terraform apply
  63. docker: Platform for developers and sysadmins to develop, deploy, and run applications with containers.

    • docker run --name web -p 8080:80 nginx
  64. kubectl: Command line tool for controlling Kubernetes clusters.

    • kubectl get pods
  65. helm: Kubernetes package manager.

    • helm install my-release mychart
  66. ufw: Uncomplicated Firewall, frontend for iptables.

    • ufw allow from 192.168.1.1 to any port 22
  67. fail2ban-client: Interface to Fail2Ban.

    • fail2ban-client status
  68. apachectl: Control interface for Apache HTTP server.

    • apachectl status
  69. mysql: Command-line tool for managing MySQL databases.

    • mysql -u root -p
  70. pg_dump: Backup database utility for PostgreSQL.

    • pg_dump -U user dbname > outfile
  71. top: Displays Linux processes.

    • top
  72. ps: Reports a snapshot of the current processes.

    • ps aux
  73. kill: Send a signal to a process.

    • kill -9 1234
  74. killall: Kill processes by name.

    • killall nginx
  75. nohup: Run a command immune to hangups, with output to a non-tty.

    • nohup command &
  76. du: Disk usage statistics.

    • du -sh /path/to/directory
  77. df: Report file system disk space usage.

    • df -h
  78. free: Display amount of free and used memory in the system.

    • free -m
  79. ln: Make links between files.

    • ln -s target link_name
  80. chmod: Change file mode bits.

    • chmod +x script.sh
  81. chown: Change file owner and group.

    • chown user:group file
  82. useradd: Create a new user or update default new user information.

    • useradd -m username
  83. usermod: Modify a user account.

    • usermod -aG sudo username
  84. userdel: Delete a user account and related files.

    • userdel username
  85. groupadd: Create a new group.

    • groupadd groupname
  86. groupdel: Delete a group.

    • groupdel groupname
  87. hostnamectl: Control the system hostname.

    • hostnamectl set-hostname newname
  88. locale: Get or set system locale and related settings.

    • locale -a
  89. date: Display or set system date and time.

    • date
  90. uptime: Tell how long the system has been running.

    • uptime
  91. who: Show who is logged on.

    • who
  92. w: Show who is logged on and what they are doing.

    • w
  93. last: Show listing of last logged in users.

    • last
  94. mount: Mount a filesystem.

    • mount /dev/sda1 /mnt
  95. umount: Unmount file systems.

    • umount /mnt
  96. reboot: Reboot the system.

    • reboot
  97. shutdown: Bring the system down.

    • shutdown -h now
  98. history: Show command history.

    • history
  99. alias: Create or remove aliases.

    • alias ll='ls -l'
  100. unalias: Remove alias definitions. - unalias ll

No comments:

Post a Comment