Skip to content

bash Linux command

The bash command is a critical tool in the Linux operating system, allowing users to interact with the shell to execute commands. It provides a versatile way to navigate directories, manipulate files, and automate tasks. By mastering the bash command, users can improve their productivity and efficiency in managing their system. With its wide range of features and capabilities, bash is an essential tool for both beginners and experienced users in the Linux environment.

Terminal window
rsync [option] [source] [destination]
OptionDescription
-aArchive mode
-vVerbose mode - increase verbosity
-zCompress file data during transfer
-rRecursive transfer
-uSkip files that are newer on the destination
-hOutput numbers in a human-readable format
ParameterDescription
sourceSpecifies the source file(s) or directory
destinationSpecifies the destination directory or location
Terminal window
ls

Displays a list of files in the current directory.

Terminal window
mkdir new_directory

Creates a new directory with the name “new_directory”.

Terminal window
cp file1.txt file2.txt

Copies the file “file1.txt” to a new file named “file2.txt”.

Terminal window
date

Shows the current date and time.

Terminal window
grep "search_word" file.txt

Searches for the word “search_word” in the file “file.txt”.

Terminal window
rm unwanted_file.txt

Deletes the file named “unwanted_file.txt”.

To use the bash command in Linux, execute the following command:

Terminal window
bash

How can I run a script using bash in Linux?

Section titled “How can I run a script using bash in Linux?”

To run a script using bash in Linux, use the following command:

Terminal window
bash script_name.sh

How can I change the default shell to bash in Linux?

Section titled “How can I change the default shell to bash in Linux?”

You can change the default shell to bash in Linux by running the following command:

Terminal window
chsh -s /bin/bash

How do I check the version of bash installed on my system?

Section titled “How do I check the version of bash installed on my system?”

To check the version of bash installed on your system, you can use the following command:

Terminal window
bash --version

How do I execute a command in the bash shell and then exit?

Section titled “How do I execute a command in the bash shell and then exit?”

To execute a command in the bash shell and then exit, you can use the following command:

Terminal window
bash -c "command_to_execute"

How do I create an interactive bash shell session?

Section titled “How do I create an interactive bash shell session?”

To create an interactive bash shell session, simply run the following command:

Terminal window
bash -i

How can I use bash to redirect standard output and errors to a file?

Section titled “How can I use bash to redirect standard output and errors to a file?”

You can use the following command to redirect standard output and errors to a file using bash:

Terminal window
command_name > output_file 2>&1

How do I set environment variables temporarily in a bash session?

Section titled “How do I set environment variables temporarily in a bash session?”

To set environment variables temporarily in a bash session, you can use the following command:

Terminal window
export VAR_NAME=value
  • Running commands in the terminal
  • Writing and executing shell scripts
  • Automating tasks through scripts
  • Managing files and directories in the Linux system
  • Navigating and manipulating the file system