r
PATH – file/folder location
v Absolute
Path – From ground to direct desire place [Full Path]
v Relative Path – From your place to direct desire place [5th floor to 10th floor]
v Relative Path – From your place to direct desire place [5th floor to 10th floor]
q
Reserved Filenames:
Ü / - The root directory (slash)
Ü . - Current directory (period)
Ü .. - Parent directory (double period)
Ü ~ - Your home directory (tilde)
Ü . - Current directory (period)
Ü .. - Parent directory (double period)
Ü ~ - Your home directory (tilde)
r
Output Redirection:
v date
> file.txt [create new file file1 and output of date command will be there]
v cal > file.txt [will override the existing file with output of cal command]
v who >> file.txt [will append the output of who command]
v su
[switch user]
v cal > file.txt [will override the existing file with output of cal command]
v who >> file.txt [will append the output of who command]
Ü su – [redirect to root user]
Ü su – shohan [redirect to normal user]
v touch file1 file2 [create empty blank file]
v rmdir * [will delete all empty directory]
Ü Copy a file
cp file1.txt file2.txt
Ü Copy a file to another directory
cp file1.txt /home/user/docs/
Ü Copy multiple files to a directory
cp file1.txt file2.txt file3.txt /backup/
Ü Copy a directory (recursive)
cp -R myfolder /home/user/
Ü cp -u * /backup [copy file only updated content inside the file]
Ü cp -n * /backup [newly create file will be copied & exist will be skip]
Ü cp /backup/file1.bkp . [dot means it will copy into current directory]
Ü Rename a file
mv old.txt new.txt
Ü Move a file to another directory
mv file.txt /home/user/docs/
mv /opt/file1 /tmp
Ü Move multiple files at once
mv file1.txt file2.txt /backup/
Ü Move a directory
mv myfolder /home/user/
r
Editor:
v gedit
file1
v nano
v vi/vim file1
Ü i/I/insert
>> insert mode
Ü Esc+A >> end of the line
Ü Esc+0 >> first line of the cursor point
Ü Esc+o >> open new line under the cursor
Ü Esc+O >> open new line above the cursor
Ü Esc+u
[undo]
Ü Ctrl+r [redo]
Ü :x
[save and exit]
Ü :wq [write and quit]
Ü :q! [exit without saving]
Ü :w [write without quite]
Ü Esc+shift:set
nu/number [set line number into file]
Ü Esc+shift:set nonu/nonumber [unset line number into file]
Ü wc
-l file1 [check how many lines into the files]
Ü 10gg
[go line number 10th]
Ü gg [go to the first line]
Ü shift+G [go to the last line]
v vi
file.txt +10 [file will be open with cursor line number 10]
v vi file.txt + [file will open with cursor last line]
Ü Line
Copy [yy]
v nano
v vi/vim file1
Ü Esc+A >> end of the line
Ü Esc+0 >> first line of the cursor point
Ü Esc+o >> open new line under the cursor
Ü Esc+O >> open new line above the cursor
Ü Ctrl+r [redo]
Ü :wq [write and quit]
Ü :q! [exit without saving]
Ü :w [write without quite]
Ü Esc+shift:set nonu/nonumber [unset line number into file]
Ü gg [go to the first line]
Ü shift+G [go to the last line]
v vi file.txt + [file will open with cursor last line]
o (n)yy
= yy[Yank] | n[No of line]
o yy
| 5yy
Ü Line Paste [p/P]
o (n)p = N time(s) Paste below the cursor
o (n)P = N time(s) Paste up the cursor
o p/p | 5p/5P
o dd
| 3dd
Ü wc
-l cat /etc/passwd
r Cat
v cat file1 /opt/file2
v cat –n file1 [n means with line number]
v cat > newfile [enter for another line then exist from file by ctrl+d]
r du -sh file1
r df -hT
r echo ‘Hello there’ >> file1
r tac [reverse text of the file]
r seq 10
r seq 10 20
r more file2 [display screen by screen/line by line content]
r less file3 [display screen by screen/line by line content, allow scroll up/down arrow]
r head file1 [will be display from top, by default 10 lines]
r head –n 5 file1
r tail file1 [will be display from bottom, by default 10 lines]
r tail –f file2 [f means follow]
Tags
RHCSA