Navigate directories: pwd / cd
To print current directory:
pwd
To navigate directories and change the current working directory.
cd directory_name
ls (List of files and directories)
# List ls # Long listing ls -l # All, including hidden ls -a
mkdir (make directory)
The basic syntax of the mkdir
command is as follows:
mkdir [OPTION]... DIRECTORY...
OPTION
: Represents various flags that alter the command’s behavior.DIRECTORY
: Specifies the name(s) of the directory(ies) you wish to create.
Basic usage
# Create directory
mkdir directory
Useful Options with mkdir
-p
(Parents)
mkdir -p parent/child/grandchild
This command creates the parent
, child
, and grandchild
directories in one go.
-v
(Verbose)
mkdir -v newdir
Output:
mkdir: created directory 'newdir'
- –
m
(Mode)
mkdir -m 755 newdir
This command creates newdir
with permissions set to 755
(rwxr-xr-x).
rm directory (remove directory)
The basic syntax of the rm
command is as follows:
rm [OPTION]... FILE...
OPTION
: Represents various flags that alter the command’s behavior.FILE
: Specifies the name(s) of the file(s) or directory(ies) you wish to delete.
Basic usage
rm file.txt
Useful options with rm
-r
(Recursive)
# Remove directory and content
rm -r directory
-f
(Force)
rm -f file.txt
The -f
option forces the removal of files or directories without prompting for confirmation. This is useful for scripts or automated tasks.
-i
(Interactive)
The -i
option prompts for confirmation before each file is deleted. For example:
rm -i file1.txt file2.txt
This command prompts you before deleting each file.