list commands
---------------------------------------------
ls - to list the files
ls -a --> to list hidden files
ls -r --> to get the list in reverse order
ls -R: Lists files in sub-directories as well
ls -al: Lists files and directories with detailed information like
permissions, size, owner, etc.
------------------------------------
Cat commands
------------------------------------
cat filename --> to display the data
cat > filename --> to create (or overwrites) the data
cat >> filename --> to append the data without deleting it's existing data
----------------------------
Wildcard characters
----------------------------
* --> to matches '0' or any
? --> matches anyone characters
[]--> matches any one character mentione in the []
- --> Range specifier
---------------------------
File cration
---------------------------
touch filename --> create an empty file
cat > filename --> create file with initial text
nano filename --> create a file and edit in nano editor
vi filename --> create a file and edit in vi editor. Advanced editing
----------------------------
File permissions
----------------------------
Owner (user) - first Ex-rwx|rwx|rwx
group - second U G Others
others - third
File permission modification
chmod --> command to change the file permission
syntax --> chmod [options] mode filename
we can change file permisson in two ways
[Link] mode:
syntax --> chmod [who][operator][permissions] filename
Ex: chmod u+x [Link] # Add execute permission to the owner
chmod go-w [Link] # Remove write from group and others
chmod a=r [Link] # Everyone can read, nothing else
[Link](Octal) representation
| Permission | Binary | Octal |
| ---------- | ------ | ----- |
| r | 4 | 100 |
| w | 2 | 010 |
| x | 1 | 001 |
Syntax --> chmod 755 [Link] # rwxr-xr-x
chmod 644 [Link] # rw-r--r--
chmod 700 [Link] # rwx------
--------------------------------
Save and exit command for Vi editor
--------------------------------
Press ESC:wq --> press Enter --> to save changes and exit
Press ESC:q --> Press Enter --> to exit with no changes
Press ESC:q! --> Press Enter --> force quit or exit without saving
:vsp --> vertical silpt for editor
:sp --> horizental split
-----------------------------
sort
-----------------------------
sort -r filename - to get data reverse order
sort -n filename - to get data numarical order
sort -nr filename - to get data numarical order
sort -k 3 filename - to get 3rd column in order
sort -nk 3 filename - to get 3rd column in alphabetical order
----------------------------
more
----------------------------
more filename --> g - begining, G - ending
more -5 filename --> o/p shows till 5 lines
more +5 filename --> o/p shows from 5 lines
---------------------
less
---------------------
less filename
less -5 filename --> o/p shows till 5 lines
less +5 filename --> o/p shows from 5 lines
------------------------
head & tail
------------------------
head -5 filename - shows first five lines
tail -5 filename - shows last five lines
-----------------
find
-----------------
find pathname -type f(file) or d(directory) -name filename
find pathname -name filename
find pathname -iname filename
find pathname -name "*.log" --> find files by extension
echo $? --> to check previous command successfully executed or not
df -kh --> to check disc space along with directories
df -kh . -->to check disc space
Package Installations:
● sudo apt-get update: Updates package lists for upgrades
● sudo apt-get upgrade: Upgrades all upgradable packages
● sudo apt-get install pkgname: Install pkgname
● sudo apt-get remove pkgname: Removes pkgname
:vsp --> vertical split
:sp --> horizental split
:1,2d --> delete 1,2 lines
:%s/oldname/newname/g --> replaces the name old name to new name
esc->v--> to come to visual mode from insert mode