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

Linux Commond

The document discusses various Linux commands for system administration tasks like checking the OS version, changing passwords, adding users, managing files and directories, and viewing processes. Key commands include uname, passwd, su, ls, cd, mkdir, touch, cat and nano.
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

Linux Commond

The document discusses various Linux commands for system administration tasks like checking the OS version, changing passwords, adding users, managing files and directories, and viewing processes. Key commands include uname, passwd, su, ls, cd, mkdir, touch, cat and nano.
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 7

LINUX COMMOND

1.uname -r = to check version of linux


2.uname = to check the name of operating system
3.$ =if you are non root user (regular user)
4.# =if you are root user(TYPE OF USER)
5.su - or sudo -i = this common is used get in root from user
6.passwd = to change the password
7./ = this indicate the root
8.~ =current directoriess
9.HOST NAME =Computer system name
10. sudo su - = it is use to go to root.
11.ls =list files
12.ls -a =list hidden files too
13.cd =change directory
14. cd .. =
15.sudo su adduser =to add user (to add user you need to be on roo ~#) (user can
be added in directories using sudo adduser "username"
16. cat /etc/passwd =it will list the user
16. compgen -u =it will list the user without details [x-encrypted
password,1002:1000(group id)-user id number,bin/bash-shell use to execute
commond,home/trial-home directory of user
16. getent passwd =it will list the user

17. userdel (username) =delete the user (IN USERNAME U HAVE TO ADD USERNAME WHICH
YOU HAVE TO DELETE)

18: GROUP:- Group is collection of users that provide the user the group of
security and privillages
HOW TO CREAT A GROUP- groupadd groupname
TO GET THE GROUP- getent groupname, less /etc/group, cat
/etc/group
TO DELETE THE GROUP- groupdel "groupname"
HOW TO ADD A USER TO GROUP- usermod -a -G "groupname" "username"
TO VIEW USER IN GROUP- id "username", NOT WORKING=id -nG
HOW TO ADD MULTIPLE GROUP TO USER- usermod -a -G "groupname1","groupname2"
"username"
HOW CHANGE USER GROUP- usermode -G "groupname" "username"

19: lINUX FILE OWNERSHIP:


2..
There are three ownership are providded which are Group User, Group and
Others
A.USER: users are the one who created the files, users some time called
as owners also
B.GROUP: Group conatins multiple user all the user that belongs to same
group will have same permision to acess to the file
C.OTHERS: Others are those who niether creted file and nor belongs to any
group.

There are three different types of permision that we gives to user.`


A.READ: User can only reads the file or can list the content of any
direccotry
B.WIRTE: owner can modify content of the file i.e add, remove,
rename
C:EXECUTE: To execute any programme user need permision.

OCTEL VALUES:
OCTAL VALUES READ WRITE EXECUTE

7 READ WRITE
EXECUTE
6 READ WRITE
5 READ EXECUTE
4 READ EXECUTE
3 WRITE EXECUTE
2 WRITE
1 EXECUTE
0

20.To creat new text file: vi text.txt (where text is file name)
21. to get out from vi : press ESC and then :q
22.to insert the vi screen: :i
23.to change the permisiom: :chmod 777 file name (first seven-owner
/ second 7=group / third 7=user)
24.TO write and quit: : to write and quit
25.change ownership file diectory :chown "username" "filename"
26.Regular to root: :sudo su ~
27.to asign group: :chown :"groupname" "filenames"
28.to verify: : ls -l
29.to change the owner :chgrp "groupname" "filename" (this
commond is used to change group ownership of given file )

DIFFRENCE BETWEEN chgrp AND chown

chgrp chown
1.we only change group ownership 1. this common changes
ownership of both user and group
(by using c=chown "�sername":"groupname" file name)

CHANGING THE OWNERSHIP USING REFRENCE: chgrp --reference=file1.txt


file2.txt

30: whoami: :display currenctly log in user


31.pwd: :working directories (starting from root)
32./bin/pwd --version: :this will give the versionn (common
version)
33.type -a pwd: :print all the location containing all
execcutable name pwd
34.y=$(/bin/pwd): :it will store the value of pwd in y
35.echo : :it will show the value of
36.$ :it holds the value

37.cd :it used to navigate or change direcotry


38.cd .. :it used to navigate current working directory
to previous working directory (root direcory)
39.cd - :previous working directory i.e
40.cd / :to system's working direcotries
41.cd :repeat working direcotires
42.cd ~ :represent default working direcotires
43.cd ~"userrname" :to go user (WORKS ONLY IN ROOT)

44.file "filename".txt :tts used to determine and tyepe of file


and its data (file type can be ascii or mime or any other type) (u need to be non
root)
45.file * :shows all files details
46.mkdir "foldername" : to make the direcotry
47.file "foldername"/* :shows the files in that directory
48. * :all
49.file["range a"-"range b"]* :it will shows the all files with lies
inbetween range a to range b defined by user , it is also called regex
50.file["range a"-"range b"]* "foldername"/* : it same as above but here it will
shows inside the folder

73.w :currently login user


72.whatis "commond" :shows the discription of commond
51.man "commond" :this commond display the manual of any commond
that we can run on terminal
52.cal :calender shows calender
53.sudo apt instal ncal : to install calender
54.ncal :shows the calender (n cal shows the
current date as comapre to cal)
55.cal 2022 :shows all year calnder
66.cal -m"monthno" :shows dedicated month calnder
67. date :gives you current date and time
68. to change the date :timdatectl set-time yyyy-mm-dd
69. to change the time :timedatectl set-time 'hh:mm:ss'
70.to check timezone :timedatectl list-timezones
71.to set time-zone :timedatectl set-timezone 'asia/kol'
74.id :this commond print user id and group id of
current user
75.id "username" :this will shows the id of user which mentioned

(where uid-user identifier this is number


which assigned by linux tu every user the no. determine which system resources used
by user)
udi=o=o is reserved for root, uid-1
to 99 reserved for other predefined account, uid- 100 to 999 is resereed for
system admistratio anf system account group, uid-1000 to 10000 is occured for
application aacoount
uid-above 100000 used by user
accout)
(where gid- determines which system
resources used by group,gid-0-root, gid-1-99- application group, gid-100+ user
group)

76.ps :this commond will give the proccess running in


system (pid is process id, tty-terminal type where user log in,time-ammount of cpu
time that a process being executing or running, cmd-name of the commmond that
launch the process)
77.ps -a :this cammond will give all the process that
are not assoicated with terminal
78.ps -e :this will gives all the cammond ehich are
related to terminal also
79.ps -r :this will give all the running cammond (stat-
process status and each code have different meaning, R+ = running, S+ = Event that
is waiting to be completed, Z- = Zombie process,X- Dead process,T- process in
waiting state)
80.ps -x :this will give all status of process
81.ps l :this will give all the details (ppid-
parent process id) BSD-Binary stastus format

82.mkdir "foldername" :this commond helpss you to creat new


filed system in dierectory
83.mkdir {foldername1,fodlername2} :this will creat multiple folder
84.mkdir -m"octal" folder name :this will create a folder with
permision (to check use ls -l)
85.mkdir -p folder/folder :this will creat a direcotry under
directory
86.mkdir -p a/{a1,a2} b/{b1,b2} :this will creat folder a and in
which creat two folder a1,a1 similary for b and b1 and b2
87.mkdir -p a1/a2/a3 b1/b2/b2 :this will creat folder a1 in which a2 in
which a3 similary for b1 b2 and b3

HOW TO CREATE FILES


88.touch "filename".extention :to creat file
89.cat >"filename" :to creat file to get exit press cntrl+d
90.echo "what u want to write" >filename :it will write it in file
91.printf "what u want to write" >filename :it will write it in file
92.cat "filename: :it will show what it is file
93.nano "filename" :to save the file user cntrl+x
94.vi "filename" :to create file and edit
95.vim "filename" :its a vim editor to exit user esc and :wq1
1.vim is advanced version of vi editor,it is
available for all widnows while vi is available on linux,
2.vim provide multiline undu where vi does not
support undo

REMOVE A FILE
96.rm :to remove a file
97.rm "filename1" "filename2" : to remove multiple files
98.rm *.file extention :to remove all extention file given by
user
99.rm -i filename :it will ask you before deleting
100.rm -f "filename" :if you dont want comfirmation prompt
while removing file(force remove)

REMOVE A DIRCTORIES
101.rm -d "directoryname" : to remove a empty directory
102.tree "direcotry name" :if u want to remove tree direcory
103.rm -r "direcortyname" :if you u want to remove parent
direcories along with its subdirecories (work with non empty direcory)
104.rm -d -i "direcory name" :to get promp msg
105. rm -d -f "direcooryanme" :to delete forcefully
106.rm -rf "direcoryname" :write protected direcotry to be remove
107.rmdir "direccortyname" :to remove folder
108.rmdir -p a1/a1/a3 :to remove whole path tree

109.cp :this commond used to copy file from


source to destination
110.cp foldername/filename destination :to copy the file from one
direcotry to antoher direcotry
111.cp "filesnames" "destination" :to copy multiple files to direccory
112.cp -r "direcory1" "direcorty2" :copy direcory , direcorty 1 to directoru
2
113.rsync -a "filename" "fldername" :it similar to copy but it uses
synchronize and transfer data to location. this commnd is use between two diff
machine
114.mv "source" "destination" :to move file from source to destination
(for same location)
115.cp --backup -S 01 "filename" "location" :to creat a backup of file (for
diffrent location)
116.mv -b "filename" foldername :backupwill have - sign
117.mv "filename" "filename" "destination" :to move multiple files to
directory (if u want to move any folder using mv stat.txt "foldername")
118.mv -n "filename" "destination" :it will move to destination and without
ovewrite it, basically it preventing the file overwritting

119.rn :to rename the file


120.mv "filename" "newname" :to rename the file using mv
cammond
121.rename -v 's/.extention1/.extention2/' *.extention :change file
extension (here s= supstitute)
121.rename -v 's/.extention1/.extention2/' filename :change file extension
(here s= supstitute) for perticular file
122.rename -v 's/"word"/"replace word"/' *extention :it will replace only
some part which user want with user word
123.rename -v 's/"word"/"replace word"/' filename :it will replace only
some part which user want with user word for file which user want
124.rename -v 's/("word"/"word2")/replaceword/' *pdf *txt :it will replcae
starting character
125.rename -v 'y/A-Z/a-z/' *txt :it will change upper
case to lower case

DIFFERENCE BETWEEN MV CP CAMMOND

MV CP

1.mv cammond is used to move or rename the file but it will 1.this will
copy file but will not delete original file
delete oeriginal file while cmoving

MV VERSUS RENAME
RENAME MV

1.Rename cammond is more advanced than mv cammomd we can 1.in mv we can not
use regular expression it is a basic cammond which used for rename
use regular expression in this

126.grep 'data' "filename" :it is used to search a pattern (gloabl


regular expression print) it will check the given data in multiple file
127.grep 'data\|data' "filename" :it will used to search multiple string
128.grep -n 'data\|data' "filename" :it will used to search multiple string
here -n shows number line
129.grep -c 'data\|data' "filename" :it will count the data given by user in
ffile that how much time it is repedted
130.sudo find /home/rohan/ "filename" :used to search specific string of
character
131.sudo find/ "filename.extention" :to search the file in whole root
132.sudo find~"filename" :search on own direcorty
133.sudo find.filename :search in current direcorty
134.sudo find -name "filename" :it will give the location of file
and displays its location
135.sudo find -iname "filename" :it will search the file with
diffrect format in name not case sensitivity
136.sudo find ~ -size "size in "kb" :it will search the search the file with
given size
137.sudo find . -type f -name '*.txt' :it will find the all the files
with given extention
138.sudo find . -name '*.extention' -delete :it will delte all file with
exxtention given
139.locate "filename" :used to find and locate direcotries or
files (even though file is delete still is shows the file)(it will not show
location after it get in first)
140.locate -e "filename" :it will not shows delted filed

DIFFERENCE BETWEEN FIND AND LOCATE

FIND LOCATE

1.this is used to search based on name type,size, 1.this


search according to previously based created datda base if u want to use located
commond u have to
ownership,permision udate
execute db commond
2.find is slower 2.locate is faster
than find (Locate can show filed location even though it is deleted)

DIFFERENCE BETWEEN GREP AND FIND

FIND GREP

1.this is used to search based on name type,size, 1.grep


is used to search pattern inside file
ownership,permision

141.ls :shows the list of files and directories


142.ls --version :shows the version
143.ls -l :shows files and directories there size modified date
and time and ownership
144.ls -a :contains all the hidden files hidden files starts
with .
145.ls -lh :shows data in bytes human readable format
146.ls -lS :it shows data in sorted format or ls -S l
147.ls -i :this check for i nodes
148.ls -R :This shwos u datda in recursive order
149.ls -lt :this will comes recent modiefied one newest to
oldest format
150.ls -d */ :this will shows all the direcotries
151.ls * :this will shows all directories in tree format
152.ls -n :this wil show u user id and group id
153.sort -o "filename" "sortedfilename" :it used to sort content
and print contatent
154.sort -o "filename""filename2" "sortedfilename" :multiple files sorting
155.sort -r "filename""filename2" "sortedfilename" :reverse sorting
156.sort -u "filename""filename2" "sortedfilename" :removes duplicate

157.ln "filename" "linkingdiname" :it used to creat a link or a


refrence to a file or folder, default it creat hardlink changes in parent file get
reflet in child and vice versa
158.ln "filename" "linkingdiname" :

HOW TO KILL PROSESS

159.kill -9 pid :to kill processby using pid

You might also like