0% found this document useful (0 votes)
10 views

linux_codeit

Linux

Uploaded by

manikanta
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

linux_codeit

Linux

Uploaded by

manikanta
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

Linux : Linux is the Enterprise server Operating System,that used in production

environment, kernel based Operating system.


Kernel is the core of the OS, that manages cpu, memory and other devices.

Just like Windows, iOS, and Mac OS, Linux is an operating system. In fact, one of
the most popular platforms on the planet,
Android, is powered by the Linux operating system. An operating system is software
that manages all of the hardware resources
associated with your desktop or laptop. To put it simply, the operating system
manages the communication between your software and your hardware.
Without the operating system (OS), the software wouldn’t function.

We need to understand this something like C drive contains OS related info, D drive
contains user related info etc.

/root
within root directory many sub-directories will be installed automatically, lets
discuss few which are more imp.

Filesystems
/etc - It Contains all the system Configuration file info - ex: u1 rename u3 then
deleted user everything gets updated in one of the file for user ref.
/usr - Contains all the Manpage information - This is the help page info like F1 in
windows, ex: #man usermod - describes the entire info about the command.
/var - System log info - diagnostic messages to diagnise the problem and find the
solution.
/opt - Contains all the the 3rd party packages installations info
/mnt - If there are any file systems mounted that stores here
/sbin - Contains all admin commands info
/bin - Contains all the normal user info
/tmp - Contains all the temporary files info - while running the application many
temporary files will be generated by the OS.
/home - It is the user default directory - ex: if we create the user its going to
create in home path, if we modify path while creating then creates in diff dir.
/proc - contains all the active PID's
/lib - Contains all library files
/media - Contains all removable devices info

*****************************************************************************
Types of shell
/sbin/sh - Bourne shell
/sbin/sch - C shell
/bin/bash - Default shell (Bourne again shell / Alive shell)
/bin/zsh - Z shell
/bin/ksh - k shell

# echo $SHELL - DIsplays the default shell

# prompt - Admin user


$ prompt - Noraml user

# useradd <username> - To create the normal user


# passwd <username> - To generate the password for the user
# su <username> - To login to the specific user

# pwd - Command to display the present working directory


# touch <FN> - Creates empty file
# cat ><FN> - Creates the file
# cat <FN> - Displays the content of the file
# cat >><FN> - Append the file
# mkdir <DN> - Create the directory
# mkdir -p - It creates multiple directories
# cd <DN> - Change Directory
# cd .. - To come one step back from the previous directory
# cd - It totally comes out of all the directories(back to home/root directory)
# clear - To clear the screen
# history - to check the history of executed commands
# date - To check the date and timings

# ls - It lists the files and directories


# ls -a - To list all the hidden and unhidden files and directories
# ls -ltr - To list files and directories in the reverse order
# ls -ll - To list the files and directories along with their permissions
# ls -i - To display the files and directories with their Inode number

# vi <FN> - To create the file


# cp <SFN> <DFN> - Copy the file
# cp -r <SFN> <DFN> - Copy the directory
# mv <SFN> <DFN> - Rename the file
# mv <SFN> <.DFN> - Hide the file
# mv <.SFN> <DFN> - Unhide the file

# rm <FN> - Delete the file


# rm -rf - Delete the directory

Disk Free Commands


# df - To check the filesystems and their sizes in blocks
# df -h - To check FS and their sizes in human readable format
# df -a - To check all the FS
# df -m - To check the FS and their sizes in Mega Byte
# df -i - To check the FS along with their Inode Numbers

***********************************************************************************
***************
Umask - Usermask Value
Purpose is to provide the security to files and directories.

022 is the pre-defined value of umask

R- 4
W- 2
X- 1
*********
RWX- 7

file - 666 (rw-rw-rw)


umask- 022
***********************
644 (rw-r--r--)

Dir - 777 (rwx-rwx-rwx)


umask-022
************************
755 (rwx-r-x-r-x)

# umask - To know the umask value

# umask 000 - Command to change the umask value to 000


***********************************************************************************
*********************
1) Absolute method

# chmod 765 <FN> - (rwx-rw-r-x)


read - 4, write - 2, execute - 1

2) Symbollic method

Owner permission - u
Group Permission- g
Other permission - o

# chmod u+x, g+w, o+x <FN>


#chmod u-x, g-w, o-x <FN>

**********************************************************************************
Links
1) Hardlink

# ln <SFN> <DFN>
* The files that are having same inode number
* Its difficult to identify the hardlink
* They are applicable only for the files within the filesystem
* Whatever we update on source file it gets updated in destination file also and
vice-versa.
* Though if we delete source file we can access destination file easily because of
same inode number, these acts as backup.
* If we delete the detination file only link will be broken but source file will be
there.

2) Softlink

# ln -s <SFN> <DFN>
* We can identify the soft links by its permissions and inode number.
* Softlinks are applicable for both files and directories.
* They can be configured across different FS.

***********************************************************************************
***
Process Management
Any task we do in OS is known as process. Each process will be having their own
PID.

PID - User reference

Daemon : Special process


It is the process that will be running continously in the background and provides
services as per the user demand.

SSH Service : Special process (SSH Daemon)


Secured Shell Protocol

Types of Process
1)Zombie Process : The process which is running without parent process
2)Orphan Process : The process which is running with parent process
3)Parent Process : The process starts itself and creates another process
4)Child Process : The process which is created by the parent process
5)Running Process : The process which is in running state
6)Sleeping process : The process which is in sleeping state.
7)Waiting Process : The process which is waiting due to resources issues, virtual
memory space issue, hardware memory issue etc.
8)Stopped Process : The process that had been completed/done with the execution and
had stopped.

# ps - To list the processes running on the current terminal


# echo $0 - to check the current shell
# sh - shift to bourne shell
# ps - listing the process running in sh shell
exit
********
# ps -ef - Lists all the process running on the OS
# ps -ef | more - Lists all the process running on the OS in detail
# ps aux | more - Advanced command to see all the Processes with their virtual and
hardware memory
# top - Command to see the proceeses that are consuming more space
# ps aux | wc -l - To check the number of processes running on the OS
# pkill <process name> - To kill the unwanted process using process name
# pkill -9 <process id> - To kill the process using process id this kills both
parent as well as child
# ps -15 <process id> - To kill only the child process or parent process alone
using their process id

***********************************************************************************
**************

You might also like