Linux Basic Command Part [2/3]

su : Used to change user account, either to super user or any other user account.
NB: In Ubuntu based linux systems, we use sudo(SUper User DO) to exicute a command with
root privilage.
Eg: sudo mkdir /abc
sudo apt-get update
script
--------------
-------------- : Records the BASH Session to the file typescript
exit

sort : Sorts a text file.

uname -a : Prints the information about the linux installed in the system.

lsb_release -a: Prints the version information about the linux installed.

Keyboard Shortcuts:


Files & Directories in Linux Systems:
• In Linux all the things excepts processes are generally considered as files(devices, 
directories, etc).
• Directories can be treated as special file that contains the list of files contained
in it.
• In the tree structure for directory all the directories contains two pointers and
which points to the current directory and parent directory respectively.
• All the files also have an inode number which along with . And .. pointers identifies
a file in the directory tree structure. Give -i option along ith ls to get the inode
number as well.
• Hidden files have names preceding with a '.'

Important Directiories in / (Root Directory):
bin : Common files shared by system, administrator and users.(Eg: commands)
boot : vmlinuz(Kernel Files), GRUB
dev : References to hardware peripherals.
etc : Configuration files(Similar to the control panel in windows)
home : Directories and home folders for users.
initrd : Information needed during booting.
lib : Library Files
lost+found : Files saved during failures.
var :Variable files like log details, server pages, temporary variables etc.
usr : Programs, libraries, documentation for all user related programs.
media : Mount points for media devices.

df -h : Gives information about the partitions.
-h : Human readable, ie. Prints the details in a way easily unstaandable by human beings.

df -h : Give the details of the disk partition that contains the present working
directory.
du -h : Prints the disk usage details for the current directory.

which : Give the absolute path for the command / program.
Eg: which ls
/bin/ls

$PATH is an environment variable that contains the list of directories which has executable files in
it. So if we give a command it will search all the folders in the $PATH variable and if it is there then
it will get executed, else it will print and error “Command not found..”.

echo $PATH : Prints the content of PATH variable.
We can temporarily change the $PATH variable using export command.
Eg:
export PATH=/usr/local/bin:/bin:/usr/sbin
or
export PATH=$PATH:/usr/sbin

$HOME :Contains the home folder for current user.
Eg: echo $HOME

file : Displays the type of the file.

cmp : Compares two files.

Searching in Linux:
Wild char symbols:
* : Matches any number of characters
? : Matches exactly one character.
[a-z] : Matches any character within the specified range.
Eg: ls *.txt
mv ./abc/*.txt ./abc/*.c

find "path" -name "search_string"
find "path" -size "size"

Eg: find /temp -name “abc.txt”
find . -size +50k

locate "search_string" : Similar to find but more friendly and less efficient.
~/.bash_history : is a file that contains the bash usage history.

grep: Command used to filter input lines and return only some patterns.
Eg: grep find ~/.bash_history
grep apple ./fruits.txt

cat : Concatenates and displays the output of one or more files to the screen.
Output displayed in an uncontrolled way.

more : Displays the output with scrolling downward option.
nano : A simple text editor.
head : Display first few lines of a text file.
tail : Display last few lines of a text file.

Go To
Linux Basic Command Part [1/3] < PREVIOUS
Linux Basic Command Part [2/3]
Linux Basic Command Part [3/3] NEXT >


Post a Comment

Mới hơn Cũ hơn