Photo by Aaron Burden on Unsplash
Linux Basic Series: Basic Linux Commands(P3)
This article explains some basic commands in Linux like how to navigate the file system using CLI and Creating, copying, moving, and deleting files.
Table of contents
This is the 3rd part of 7 part series where I explain the Basics of Linux.
Navigating the file system using the command line.
Current Working Directory
The 'pwd' command prints the current working directory.
pwd
In your case it will show /home/{your-username}
List Current files and Directory
The 'ls" command lists the files and directories in the current directory.
ls
"ls -a" will list all the files and directories present in the current directory including hidden files.
ls -a
(The names beginning with '.' are hidden files and directories)
"ls -l" will list the files and directories present in the current directory in a list view giving details such as
ls -l
The task for you is to think what "ls -al" command will do.
Change Directory
The 'cd' command allows you to change the current directory to a new directory.
cd /Desktop
"cd " will take you to your current users home directory(which is /home/abhi in my case).
cd
"cd .." will take you to your parent directory. The directory that the current directory is inside of. (here ".." signifies the parent directory)
cd ..
Create, copy, move, and delete files and directories
Make new directory
The 'mkdir' command creates a new directory.
mkdir fold1/
The above command will create a new directory of the name 'fold1' in your current directory.
Create a new file
The 'touch' command creates a new file in your current directory.
touch date.txt
Copy file or directory
The 'cp' command copies a file or directory to a new location.
cp date.txt fold1/
The above command will copy the file 'date.txt' to inside the folder 'fold1'
Move file or directory
The 'mv' command moves a file or directory to a new location.
mv date.txt fold1/
The above command will move the file 'date.txt' from its original location to inside the directory fold1/.
Remove file or directory
The 'rm' command deletes a file or directory.
rm date.txt
The 'rmdir' command only removes an empty directory.
rmdir fold1
Date and Time
The 'date' command gives the current date.
date
The 'cal' command gives the current month
cal