-
apropos
apropos "remove files" -
whatis
whatis rm
-
man
man man
You can use
forbto move forward or backward and use/can be used to search for specific term and press enter to search for next occurrence./browser
qcan be used to quit.man 7 man
here
7is 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 -
whichtells the location of the program -
touchcreates a file with the given file name -
pwdprint working directory -
cdis used to change the directory -
cpis used to copy.cp source destination. Last argument is the destination, so you can copy more than one file. -
mvis used to relocate the file/directory. Also used to renamemv myfile myfile2 #rename mv myfile2 Documents #move
-
rmis to delete a file -
mkdircreates a directory(Cannot be space separated)mkdir my directory #creates two directory mkdir "my directory" #created a directory mkdir my\ directory2 #creates a directory
-
rmdirremoves the directory -
truncateis used to create files of different sizestruncate -s 1MB file1
-
findfind . -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
ffor file,lfor link,cfor character device,bfor block device. -
echotakes 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
-
stderrhas 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
-
diffis to find the difference in two filesdiff -y file1.txt file2.txt diff -u file2.txt file2.txt
-
cmpto 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 + eend of linectrl + astart of the linectrl + jto justifyMisesc^isshiftctrl + _to go to a line numberctrl + kto cutctrl + uto 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.txtln 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.txtArchives: combines files into one file
Compression: reduce the size of a file
-
tar: Tape ArchiveDoes linear scanning
tar -cf docs_archive.tar *-cis for create-fis 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
-tis for tarUnpack
tar -xf docs_archive.tar -C extract_folder
-xto extract -
GzipandBziptar -czf files.tgz file*.txt text*
-zis for Gzip-jis for Bzip -
zipzip 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
-
awkis 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
