50 Must-Know Bash Commands for Linux & Unix Sysadmins

As a system administrator, having a solid command of the bash shell is an indispensable skill. Bash, the Bourne-Again SHell, is the default shell for most Linux distributions and macOS, and it provides a powerful command-line interface for managing and automating system tasks. In this blog post, we'll explore 50 must-know Bash commands that every Linux & Unix system administrator should have in their toolkit, organized by topic for easy reference.

File and Directory Management

Effective file and directory management is a fundamental aspect of system administration. This group of commands allows you to navigate through the file system, create and delete directories, move and copy files, and perform various operations on files and directories.

  1. ls - List the contents of a directory.
  2. cd - Change the current working directory.
  3. pwd - Print the current working directory.
  4. mkdir - Create a new directory.
  5. rmdir - Remove an empty directory.
  6. rm - Remove files or directories.
  7. mv - Move or rename files and directories.
  8. cp - Copy files and directories.
  9. touch - Create a new file or update the timestamp of an existing file.
  10. find - Search for files and directories based on various criteria.

File Viewing and Manipulation

As a system administrator, you'll often need to view, search, and modify files. The following commands enable you to read file contents, search for patterns, edit files on the fly, sort and filter data, and compare differences between files.

  1. cat - Concatenate and display the contents of one or more files.
  2. less - View the contents of a file one page at a time.
  3. head - Display the first few lines of a file.
  4. tail - Display the last few lines of a file.
  5. grep - Search for patterns in files or input.
  6. sed - Stream editor for editing files.
  7. awk - Pattern scanning and processing language.
  8. sort - Sort lines of text files.
  9. uniq - Report or omit repeated lines.
  10. diff - Compare files line by line.

System Information and Management

Monitoring and managing system resources is a critical part of system administration. The commands in this group provide valuable information about the system's hardware, memory usage, running processes, and scheduling tasks. They help you maintain system stability and optimize performance.

  1. uname - Print system information.
  2. uptime - Show how long the system has been running.
  3. free - Display the amount of free and used memory.
  4. top - Display and manage the top CPU processes.
  5. ps - Report a snapshot of the current processes.
  6. kill - Terminate a process by its process ID (PID).
  7. killall - Terminate processes by name.
  8. reboot - Restart the system.
  9. shutdown - Shut down the system.
  10. crontab - Schedule tasks to run at specific times or intervals.

User and Permission Management

Properly managing user accounts and permissions is essential for maintaining system security and controlling access to resources. The commands below allow you to create, modify, and delete user accounts, manage groups, and set appropriate file and directory permissions.

  1. useradd - Create a new user account.
  2. userdel - Delete a user account.
  3. usermod - Modify a user account.
  4. groupadd - Create a new group.
  5. groupdel - Delete a group.
  6. groupmod - Modify a group.
  7. chown - Change the owner of a file or directory.
  8. chgrp - Change the group ownership of a file or directory.
  9. chmod - Change the permissions of a file or directory.
  10. su - Switch to another user account.

Network and Remote Access

In today's interconnected world, system administrators often need to manage systems remotely or troubleshoot network issues. These commands enable you to test network connectivity, configure network interfaces, securely access remote systems, transfer files, and automate various network-related tasks.

  1. ping - Test connectivity to a remote host.
  2. ifconfig - Configure network interfaces.
  3. ssh - Secure Shell for remote login and file transfer.
  4. scp - Secure Copy for transferring files over SSH.
  5. rsync - Synchronize files and directories between two locations.
  6. ftp - File Transfer Protocol for transferring files.
  7. nc (or netcat) - Read and write data across network connections.
  8. nmap - Network exploration and security auditing tool.
  9. wget - Retrieve files from the web.
  10. curl - Transfer data using various protocols.

Summary

Mastering Bash commands is crucial for system administrators to efficiently manage Linux and Unix systems. These 50 must-know commands, each with a variety of options to tailor their behavior, equip sysadmins with a powerful arsenal. From navigating file systems and manipulating data to monitoring system resources and managing user access, these commands offer unparalleled control and flexibility.

Their versatility lies in the ability to modify their functionality through command-line options, enabling administrators to perform complex tasks with precision. Whether you're a seasoned veteran or a budding sysadmin, proficiency in leveraging these commands and their extensive options will empower you to streamline administrative workflows, optimize system performance, and maintain a secure and efficient computing environment.


This post was written by Ramiro Gómez (@yaph) and published on . Subscribe to the Geeksta RSS feed to be informed about new posts.

Tags: guide linux sysadmin

Disclosure: External links on this website may contain affiliate IDs, which means that I earn a commission if you make a purchase using these links. This allows me to offer hopefully valuable content for free while keeping this website sustainable. For more information, please see the disclosure section on the about page.


Share post: Facebook LinkedIn Reddit Twitter

Merchandise