Linux Commands

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 4

Linux commands

->pwd :- present working directory or print working directory to see present


location or in which directory we are in right now.

->whoami:- current user logged in name.

->date:- it gives date time with seconds just to see date then {date +%D} for time
{date +%T}, {date +%H:%M} will give time but only hour and minutes.

-> ls-> it gives all the present files and folder in that directory folder might
be in bold or different color.

->ls -lt :- it will show present files and folder with detailed explaination like
last modified time ,size ,read write expand permits.It basically sort files on the
basis of their date and time of modification if we do {ls -ltr} then it sorts in
revers order using above criteria.

->ls -lh:- it gives size in human readable format.like k,mb.

==> In all ls -lt or ltr or lh it shows - before r,w,e for files and d before
r,w,h for folder.

->clear:- it just clear the terminal without exiting directory.


or we can use ctr+l shortcut to clear terminal.

->cat <filename>:- it will show the contents of that file.

->less <filename>:- it is also used to read the file but in last line if we
add{/virat} then it will show all instances where virat is there in that file by
pressing n we can see another instance of that word in that file.By pressing
"shift+g" we can go directly to that last line of that file.
"shift+p" to go to first line. {? virat} it will show instances where virat is
present from that file rest is same .By pressing "q" we get out of that file.

->more <filename>:- it is also used to read a file but it show content pagewise by
pressing arrow keys.

->touch <filename> :-it create a new file in that directory where we are passing
that command.
->rm <filename> :- it removes that file from that directory.

->vi <filename> :- it will create file in that directory and let us to edit it just
after it.by pressint "i: we can write in it .after editing or writting we need to
press esc key then to save that file we need to press "shift+;".then by pressing
"wq" we can come out of that file editor and back to terminal.

->nano <filename>:- it autosuggest using tab and we can edit a file.

->mkdir <filename>:- makedirectory it makes new folder.

-> rmdir<dir_name>:- it is used to delete folder or directory. {rm -rf <dir_name}


also does the same thing.

->cd <dir_name>:- to get into new folder.

-> cd .. :- it will take u one folder backfromthe present dir.


->we can give multiple folder name seperating them by / without space after cd to
directly get into it.
-->||ly cd../.. will take two folder back.

---> "/" this is called as home dir.

->if we give full path from root loc to final then it is called absolute path.if we
give only final folder name or dir with respect to that then it is called relative
path.

-> cp <file> /dest/path:- This is copy command first we give filename which needs
to be copied then final dest where it neds to be copied.

-->"." it means present directory if previous dir have some file to be copied to
this dir then {cp ../<fn> .}.

-> cp <fn> <fn>:- in this content of first file get cpy paste in second file.

->mv <fn> <folder_name>:- it will move or cut-paste fn file from current dir to
folder_name dir.

--> we can rename filename by giving new name on second place of mv command rather
than giving dir.

->touch <fn>{1..10}:-it will create 10 fileasin that directory.

->shuf <fn>:- it shufles the lines of content.

->wc -l <fn>:-It counts no of lines in that file.

->cmp fileA fileB:-It checks wheather two files are identical or not.

->diff fileA fileB:-It also checks for difference in two filesit tells the lines
which are different in those two files.

->find /path/ -name <file>:-it finds that file in given path.

->locate <fn>:- it locates that file from its cache database so first we need to
use update command.

->history | grep commname:- it will show that command used previously.

->man commname:- it gives info about that command.

->bc:- it is binary calculator where we can do basic calculations.

->uptime:- it will give for how many time linux server is working and how many
users are logged in.

->script :- it keeps on recording all commands after this in a typescript file.

-> gzip -k <fn>:-it creates compressed version of that file.

->gunzip <fn>:it decompresses the zipped file.

->tar -czf <fn>.tar.gz <foldername/>:- it creates archived version of that folder.

->tar -xzf <fn>.tar.gz :-It decompress that folder.


->zip myfiles.zip file1 file2:- It compresses both files at once and put it in
myfiles.zip folder.

-> unzip

File system:-

->everycommand is in file in linux we can see that by whereis command.

->lsblk -f :-show u file system of your system.

->

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy