0% found this document useful (0 votes)
40 views5 pages

Basic Commands Updated

Uploaded by

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

Basic Commands Updated

Uploaded by

teyesi4982
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

1.

to create a directory(folder)

#mkdir directoryname(folder name)

2. to create multiple folder(directory ) at time

#mkdir folder1(folder name) folder2(folder name) folder3(folder name)

3. to create branch folder

#mkdir -p /foldername/foldername/foldername

4. to create multiple folder in a folder

#mkdir -p /folder1/{folder2,folder3}/{folder4,folder5}

5. to delete a empty directory(folder)

#rmdir directoryname(foldername)

6. to delete a directory with content

#rm -rf directoryname(foldername)

7.to create a blank file

#touch filename

8. to create a file .

#cat>filename

write any thing

ctrl+c(to save)

9.to create file in graphics mode

#gedit filename

type anything and save

10. to create or edit a file

#nano filename

write anything

ctrl+O(to save)
ctrl+x( to exit)

11. to create or edit file

vi/vim(visual editor/advance visual editor) command is used to create file


vi command operate in 3 modes

a)command mode:- to run some command


b)insert mode :- to type or write anything
c)execute mode:- to save and exit from a file

#vi filename

command mode

:se nu( to set line number)


:2( to move the cursor to that line)
/wordname (to serach a word)
:%s/old word name/new word name/g ( to find and replace a word)
yy( to copy a single line)
3yy( to copy 3 line from cursor)
p( to pase one time)
4p( to paste 4 time)
dd( to delete single line)
3dd( to delete 3 line)
x( to delete single character)
5x( to delete multiple character)

to move the cursor


l(to move right side)
h(to move left side)
k(to move upward)
j(to move downward)

inset mode

press i or insert key

esc (to exit from insert mode)

execute mode

:q( to quit without saving file)


:q!( to quit without saving forcefully)
:w( to save and remain in the edit mode)
:wq( to save and quit)
:wq!( to save and quit forcefully)

12. to delete a file

#rm filename
press y for confirmation

13. to see list of file and folder

#ls( to see only name of file and folder)


#ls -l ( to see the list of file and folder with details)
#ls -lh( to see the list of file and folder in human readable size format)
#ls -lhi( to see the list of file and folder in human readable format with inode
number)
13.to change directory

#cd foldername ( to enter into a directory)

#cd .. ( to exit from a folder)

#cd ../.. ( to exit 2 folder)

#cd - ( to go to previous location)

#cd ~ ( to go to home directory)

14. to know to present directory location

#pwd( present working directory)

15. to copy file

cp file2(file name) /data(destination location)

if you want to copy a file but save with different name

cp file2(file name) /data/file3(destination with new file name)

to copy all files from a folder

cp foldername/* /data(destination location)

16.to move a file

mv /root/Desktop/a(file name with path) /data(destination location)

17. to rename a file

mv oldfilename newfilename

18.to backup a file

tar -cvf(copy verbose file) /data/file3.tar(backup file name) file3(filename)

19 to restore file

tar -xvf(extract verbose file) /data/file3.tar(backup file name)

20.to compress a file

bzip2 filename

or
gzip filename

21. to uncompress a file


bunzip2 file2.bz2(compress filename)

or

gunzip file2.gz(compress file name)

22. to count the number of line ,word and character in a file

wc filename

wc -l filename (to count line number)

wc -w filename (to count word number)

wc -c filename (to count character number)

23. to shutdown

init 0

or

poweroff

24. to restart

init 6

or

reboot

25. to logoff

logout

or

press CTRL+d

26.to see the list of used commands

history

27.to see the list of currentaly login user to all terminal

who

or

w
28.to see the current user login to the terminal where currentaly working

who am i

29.to get a help about command

command name(mkdir) --help

or

man commandname(mkdir)

You might also like