-
apropos
apropos "remove files"
-
whatis
whatis rm
-
man
man man
You can use
f
orb
to move forward or backward and use/
can be used to search for specific term and press enter to search for next occurrence./browser
q
can be used to quit.man 7 man
here
7
is the section which you want to look at. -
info
info git
-
help
help if
The Linux File Hierarchy Structure or the Filesystem Hierarchy Standard (FHS) defines the directory structure and directory contents in Unix-like operating systems.
-
ls
-l
: vertical view-a
: show hidden files as well-R
: recursively go inside each directory -
file <filename>
-
stat
-
which
tells the location of the program -
touch
creates a file with the given file name -
pwd
print working directory -
cd
is used to change the directory -
cp
is used to copy.cp source destination
. Last argument is the destination, so you can copy more than one file. -
mv
is used to relocate the file/directory. Also used to renamemv myfile myfile2 #rename mv myfile2 Documents #move
-
rm
is to delete a file -
mkdir
creates a directory(Cannot be space separated)mkdir my directory #creates two directory mkdir "my directory" #created a directory mkdir my\ directory2 #creates a directory
-
rmdir
removes the directory -
truncate
is used to create files of different sizestruncate -s 1MB file1
-
find
find . -name apple #search if file named apple exists find . -name "*apple*" #search for files apple in the file name find . -size -10M #files with size less than 10M find . -size +10M #files with size greater than 10M find . -name "lemon" -type d #returns only directory
f
for file,l
for link,c
for character device,b
for block device. -
echo
takes text as input and returns it as outputecho "krishna"
-
>
replaces the contents but>>
appends to the file. -
|
chains the commands. send the output of one command as input to other.ls | wc
-
<<
Is for hearingwc << over > This so something > over
-
stderr
has code 2ls docs 2> errout.txt #if output is there then it saves in errout.txt find / -name "home" 2> error.txt 1> output.txt
-
diff
is to find the difference in two filesdiff -y file1.txt file2.txt diff -u file2.txt file2.txt
-
cmp
to compare byte by bytecmp file1.txt file2.txt #first difference cmp -l file1.txt file2.txt #all difference
-
hexdump
*
zero or more character?
one character
ctrl + e
end of linectrl + a
start of the linectrl + j
to justifyM
isesc
^
isshift
ctrl + _
to go to a line numberctrl + k
to cutctrl + u
to paste
Two modes: command and insert
Command modes takes key strokes as command and insert mode let you type in a document.
i
is used to go to insert mode. esc
to go back to command mode.
:w
to save
:q
to quit
In command mode use /
and then text to search.
Use ^
to move to the beginning of a line and $
to move to the end.
- Hard link and Soft(symbolic) links
- Hard link point to inode (address).
- Soft link points to the file name(renaming breaks the soft link)
ln -s /home/krishna/users.txt Documents/user-list.txt
ln
is for link, -s
is for symbolic and then full absolute path and then destination. Relative path will is not used a system will use the relative path from where the sym link is, so it will point to users.txt
in Documents
Hard Link:
ln /home/krishna/users.txt Documents/list.txt
Archives: combines files into one file
Compression: reduce the size of a file
-
tar
: Tape ArchiveDoes linear scanning
tar -cf docs_archive.tar *
-c
is for create-f
is to tell that it should redirect the output to a file*
here tells that archive all the filesList all the files in a archive
tar -tf docs_archive.tar
-t
is for tarUnpack
tar -xf docs_archive.tar -C extract_folder
-x
to extract -
Gzip
andBzip
tar -czf files.tgz file*.txt text*
-z
is for Gzip-j
is for Bzip -
zip
zip myfiles.zip * unzip myfiles.zip -d unzipped #-d to specify a folder
-
z{2}
search forzz
-
\.
search for.
-
^
beginning of line$
end of linecat users.txt | grep -E ".*" cat users.txt | grep -E "a" cat users.txt | grep -E "[Aa]" cat users.txt | grep -E "[A-M][a-g]"
-
sed
: stream editorcat users.txt | sed 's/e/d/' #s is for substitute (replace the first `e` with `d`) cat users.txt | sed 's/e/d/g' #`s` is for substitute (replace all `e` with `d`) and `g` is for greedy cat users.txt | sed 's/[A-Ea-e]/_/g' cat users.txt | sed 's/\ *//g' #gets the first name
-
awk
is for reformattingcat users.txt | awk '{print $2}' #print item 2 cat users.txt | awk '{print $2 ", " $1}' #print item 2 , item 1 cat users.txt | awk '{print $2 ", " $1}' | sort
sudo apt install openssh-server
ip a #to check ip address
ssh user@ip
-
SFTP: SSH File Transfer Protocol
sftp user@ip get file3 #to download put fil3 # to upload
-
SCP: Secure Copy Protocol
scp user@ip:<location_file> . #download scp file4 user@ip:<location> #upload