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.
ls
- List the contents of a directory.cd
- Change the current working directory.pwd
- Print the current working directory.mkdir
- Create a new directory.rmdir
- Remove an empty directory.rm
- Remove files or directories.mv
- Move or rename files and directories.cp
- Copy files and directories.touch
- Create a new file or update the timestamp of an existing file.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.
cat
- Concatenate and display the contents of one or more files.less
- View the contents of a file one page at a time.head
- Display the first few lines of a file.tail
- Display the last few lines of a file.grep
- Search for patterns in files or input.sed
- Stream editor for editing files.awk
- Pattern scanning and processing language.sort
- Sort lines of text files.uniq
- Report or omit repeated lines.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.
uname
- Print system information.uptime
- Show how long the system has been running.free
- Display the amount of free and used memory.top
- Display and manage the top CPU processes.ps
- Report a snapshot of the current processes.kill
- Terminate a process by its process ID (PID).killall
- Terminate processes by name.reboot
- Restart the system.shutdown
- Shut down the system.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.
useradd
- Create a new user account.userdel
- Delete a user account.usermod
- Modify a user account.groupadd
- Create a new group.groupdel
- Delete a group.groupmod
- Modify a group.chown
- Change the owner of a file or directory.chgrp
- Change the group ownership of a file or directory.chmod
- Change the permissions of a file or directory.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.
ping
- Test connectivity to a remote host.ifconfig
- Configure network interfaces.ssh
- Secure Shell for remote login and file transfer.scp
- Secure Copy for transferring files over SSH.rsync
- Synchronize files and directories between two locations.ftp
- File Transfer Protocol for transferring files.nc
(ornetcat
) - Read and write data across network connections.nmap
- Network exploration and security auditing tool.wget
- Retrieve files from the web.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.
Featured Merch
Latest Posts
- Manage Long-Running Tasks with Screen on a Remote Linux Server
- Troubleshooting External Hard Drives on Linux
- How to Prevent SSH Timeout on Linux Systems
- Getting Started with Print-on-Demand Merchandise
- Understanding the Bash Fork Bomb: A Breakdown of :(){ :|:& };:
Featured Book
Subscribe to RSS Feed
This post was written by Ramiro Gómez (@yaph) and published on . Subscribe to the Geeksta RSS feed to be informed about new posts.
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