0% found this document useful (0 votes)
28 views

Basic Commands

Uploaded by

Ajay 19cse003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Basic Commands

Uploaded by

Ajay 19cse003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

1.

date – To Print Current date and time


2. cal – To print current month Calender
cal -3 - print 3 months (previous,current,next) calender
cal -y - print current year calender
cal -y 2025 - print 2025 year calender
3. history – To print terminal commands history
history -c - To clear terminal commands history.
4. clear - clear terminal window/screen
5. pwd - present working directory
6. ls - list contents of s directory
ls -l - long list (permissions, user, group, date & time)
ls -la - to show hidden files.
ls -ld - to check directory details.
ls -ldZ - to check directory context.
7. ls+Double Tab - To show all possibilities to execute a command
8. lscpu - To show details about CPU
9. lshw – To show system Hardware Details
10.help - to see help menu of a command
ex: ls --help
11.man - display manual pages of a command
ex: man ls
12.whoami – Show currently logged in user
13.whatis - display one line description of a command
ex: whatis ls
14.whereis - to check location of a command and its man pages
15.lsblk - to display partition information
16.pwd - to check present working directory
17.cd - change working directory
cd <path> - to go a directory of given path
cd .. - to go the parent directory
cd ../../../ - to go 3 directories back
cd - - to go to the previous directory
cd - to go to the users profile/home-dir
18.echo - to print a line of text in terminal
echo "line of text" - print in terminal
echo "line of text" > filename - create new file cat with
echo "line of text" >> filename - add line of text to echo file
19.cat - print data of a text file in terminal
cat echo - print in terminal
cat echo > cat - create new file cat with echo file text
cat echo >> cat - add echo file text to cat file
20.touch - to create a bank file
touch filename
21.cp - to copy a file from one dir to another dir.
cp <source-file-path> <Destination-path>
cp echo /root
22.mv - to move a file or dir. to a new dir.
mv <source-path> <Destination-path>
mv test mvtest - to rename a file or dir.
23.mkdir - To create new directory
Ex: mkdir Songs
mkdir –p - To create parent directory
Ex: mkdir -p Songs/MP3/Punjabi
24.rmdir – To remove a blank directory
rmdir <directory-path>
25.rm – To delete a file or directory with data
rm <file-path> - To delete a file
rm -r <dir-path> - To delete a directory
rm -rf <file-path/dir-path> - Delete file/dir and never
prompt for yes/no
26.Tree – To see contents of a directory in Tree format.
Tree <directory-path>
27.Head – To print starting 10 lines of a text file
Head <File-path>
Head -n <no.of lines> - to print starting given no. of
lines from a text files
28.Tail – To print last 10 lines of a text file
Tail <File-path>
Tail -n <no.of lines> - to print last given no. of
lines from a text files
29.grep = to print a text or pattern from a text file
syntax: grep <options> "<pattern>" file-path
grep "pattern" filename
-c = print no. of matches
grep -c "pattern" filename
-i = ignore-case
grep -c "pattern" filename
-n = line number
grep -n "pattern" filename
-v = print lines without match
grep -v "pattern" filename
30.alias - to create a shortcut of a command.
syntax: alias <shortcut> = <command>
alias c=clear
alias l=ls
31.sort - to sort data of a text file and print in terminal.
syntax: sort <options> filename
sort: sort data alphabetically.
sort filename
sort -r: sort data alphabeticall in reverse string.
sort -r filename
sort -n: sort data numerically.
sort -n filename/path
sort -f: sort data in case sensitive string (alphabetically but
Capital first then small letters)
32.less - divide a long file into readable bits.
Syntax: less <file-path>
(show only one page of a file.)
Down arrow key - show next line
enter - show next line
space - go to end of file
After end of file press "q" to exit
33.more - divide a long file into readable bits.
Syntax: more <file-path>
(show only one page of a file.)
enter - show next line
space - go to end of file
34.|(pipe) - to use two or more commands at the same time.
use output of one command as input to
other command
syntax: command1 | command 2 | command 3

35.top – to check running process details


to kill a process “ press k”
then type the PID(process ID) of process to kill
hit enter twice
36.kill – to kill a process
kill <process-id>
37.df – to check file system information and free disk space
df -T - to show type of file system
df -h - to show in human readable form(K,M,G)

You might also like