Bash, the Bourne Again Shell, offers a powerful set of basic commands that form the foundation of command-line operations. These commands enable users to navigate the file system, manipulate files, and manage system processes efficiently.
Navigating the file system is a crucial skill for any Bash user. Here are some essential commands:
pwd: Print Working Directory - displays the current directoryls: List - shows the contents of the current directorycd: Change Directory - moves to a different directoryExample usage:
$ pwd
/home/user
$ ls
Documents Downloads Pictures
$ cd Documents
$ pwd
/home/user/Documents
Bash provides several commands for creating, copying, moving, and deleting files:
touch: Creates a new empty filecp: Copies files or directoriesmv: Moves or renames files or directoriesrm: Removes files or directoriesHere's an example of file manipulation:
$ touch newfile.txt
$ cp newfile.txt backup.txt
$ mv backup.txt old_backup.txt
$ rm newfile.txt
To view file contents, use these commands:
cat: Displays the entire file contentless: Allows scrolling through large fileshead: Shows the first few lines of a filetail: Displays the last few lines of a fileBash offers commands for system-related tasks:
date: Displays the current date and timewhoami: Shows the current userps: Lists running processestop: Displays real-time system statisticsWhen you need help with a command, use:
man: Displays the manual page for a command--help: Shows a brief help message for most commandsFor example: man ls or ls --help
sudo when necessary.Mastering these basic Bash commands is essential for efficient command-line operations. As you become more comfortable, explore advanced features like Bash Pipes and Bash Input/Output Redirection to enhance your command-line productivity.