Bash Basic Commands
This tutorial will cover the absolute basics you need to start navigating and interacting with your Unix/Linux file system.
We'll focus on:
- Listing files and directories (
ls
) - Changing directories (
cd
) - Printing your current directory (
pwd
)
1. Bash Listing ls
It allows you to see the contents of a directory.
Example output:
Some Important Options With ls
-l
- Long listing format-a
- Include hidden files
Examples:
You can also write all options at once
2. Bash Change Directory cd
The cd
command (short for "change directory") is how you navigate through your file system.
To move into a specific directory, type cd
followed by the directory's name.
You have to go to home directory to change directory to Documents
.
After this command, your current location in the terminal will be inside the Documents
directory.
Options With cd
- (Go Up One Level):
cd ..
This command moves you to the one level up directory from your current location. - Switch to the previous directory:
cd -
- Change to the root directory:
cd /
- Change to the home directory:
cd ~
- The
cd ~
command takes you to your home directory, which is the default directory for your user account.
- The
3. Bash Print Directory pwd
The pwd
command (short for "print working directory") simply tells you your current location in the file system. It's like asking "Where am I?"
Example output:
Next we will learn about File handling in bash