Basic Linux commands
CD command in Linux with example
command to return to the home directory immediately, use cd ~ OR cd
command to change into the root directory of Linux file system, use cd /
command to go into the root user directory, run cd /root/ as root user.
command to navigate up one directory level up, use cd ..
command to move preview directory cd ../
command to go back to the previous directory, use cd -
SU command in Linux with example
SU Means - Switch User
PWD command in Linux with example
pwd - present working directory
LS command in Linux with example
$ ls- list file or directory
$ ls - l (list file or directory - long list)
$ ls - a (list file or directory - Hidden list)
$ ls -1 (Display One File Per Line)
$ ls -lh (Display File Size in Human Readable Format)
$ ls -lt (Order Files Based on Last Modified Time)
$ ls -ltr (Order Files Based on Last Modified Time in Reverse Order)
Touch command in Linux with example
touch file.txt (Create a file)
touch file1.txt file2.txt (Create Multiple Files)
Touch-a - change the access time only
Touch-c - if the file does not exist, do not create it
Touch-d - update the access and modification times
Touch-m - change the modification time only
Touch-r - use the access and modification times of file
Touch-t - creates a file using a specified time
vi / vim text editor command in Linux with example
You can use VI edit to edit file
$vi file1.text
VI Editing commands
i – Insert at cursor (goes into insert mode)
Esc - Terminate exit insert mode
:wq! - Save file (Exc and :wq! + Enter)
cat or more command in Linux with example
cat or more command use to view the contents of a file.
$ cat file.txt file1.txt (Display two files)
$ less file.txt
$ head file.txt
$ head 15 file.txt (display first 15 lines)
$ tail file.txt
$ tail n file.txt (display last n lines of a file)
cp command in Linux with example
cp command use to copying files and directories
$ cp file1.txt filebackup_23012022.txt
rm command in Linux with example
rm command is used to remove a file.
Basic Linux command about directory
mkdir command in Linux with example
mkdir command use to create directory (directory)
$ mkdir --version (check directory version)
$ mkdir dir1 (create a single directory)
$ mkdir dir1 dir2 dir3 (create a multiple directory)
$ mkdir -p tech/techopss/backup
(create multiple sub directories - parent directories)
$ mkdir -m777 dir1(set access to dir5 folder to all users)
rm -r command in Linux with example
rm -r command use to remove directory
rm -r (remove non-empty directories use recursive -r)
rm -d ( remove an empty directory use -d)
rm -rf (command use to remove directory forcible delete (Yes you want to delete this directory will not ask)
cp -r command in Linux with example
$ cp-r (use to copy directory to another directory)
Post a Comment