The document discusses Linux run levels and how to manage users, files, directories and permissions in Linux. It provides details on the different run levels like single user mode, multi-user mode etc. It also summarizes commands for user administration, file permissions, editors, mounting devices and file system management including logical volume management.
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
105 views
Linx Command
The document discusses Linux run levels and how to manage users, files, directories and permissions in Linux. It provides details on the different run levels like single user mode, multi-user mode etc. It also summarizes commands for user administration, file permissions, editors, mounting devices and file system management including logical volume management.
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11
Run level
1:-- initinit define run level 0-6 ,S., emergency
The run level is selected by #id:5:init default: 2:-- Show current and previous run level #/sbin/runlevel Run level
Run level Command Use 0 #init 0 Halt (Shutdown) 1 #init 1 Single user mode 2 #init 2 Multi user mode without NFS 3 #init 3 Multi user mode full access s 4 #init 4 Officially undefined 5 #init 5 Graphical user login for Desktop & Laptop 6 #init 6 Restart S #init S Alternative single user mode Emergency #init emergency By pass, rc sysinit, su login
# :-- root user $ :-- normal user
Shortcut Shortcut and command Use of Ctrl+Alt+f1 GUI mode Ctrl+Alt+f2 CUI mode
Ctrl+Alt+f3 Multi user Ctrl+Alt+f4 Multi user Ctrl+Alt+f5 Multi user Ctrl+Alt+f6 Multi user Ctrl+Alt+f7 Multi user #who Show all login interface #who am i Current prompt #clear Clear screen #exit Switch user #cd / Open root #dir Show all directory #cd Close directory #ls l Show file list
Create Directory #mkdir filename(raj) #dir Create file #cat > filename(raj) Ctrl+d ( save file ) To read the contain of a file #cat filename(raj) Extend of the file #cat >> filename(raj) Command Use of the cmd
#ls To read the contain of the file #cd dirname(raj) Change the directory #rmdir dirname(raj) Remove the directory(when dir is empty) #rm rf dirname(raj) Delete contain directory #rm filename(raj) #Y Delete the file
User Administration Its used to create the user. #useradd option username(raj) Where Option is -d Home directory -S Define shell -c Comment -g Define group ID -u Define user ID -l Login name #adduser username(raj) Add group Syntex::- groupadd option usename(raj) Where option is
-f Forcefully -g Define the group ID
#groupadd groupname(raj) #cat /etc/group Show the group and user information #cat /etc/passwd Show the user information
Delete User #userdel option username(raj) #userdel username(raj) Where option is -r Recursible -f forcefully
Group delete Syntex::- groupdel option groupname(raj) #groupdel groupname(raj) Add password to a user #passwd username(raj) New password- Conform password- Successfully
Password age of a user #chage option username(raj) Where option is -m Minimum age -M Maximum age
To view the user password information #cat /etc/shadow Change the ownership of a file #chown newname file/dir name #chown raj vijay
Change ownership of a group #chgrp newname groupname #chgrp kajal raj Add user to a group #usermod G groupname username
Command #w Connect user #last Login and reboot history #lastb Failed login attempt #lastlog Login user information
File permission Methods:-- 1:-- Character mode or Symbolic mode 2:-- Digit mode or Numbering mode File Character mode Digit mode Read r 4 Write w 2 Execute x 1 Full accress rwx 7 Read&write rw- 6
Read & execute r-x 5 +:-- Add character mode -:--Remove character mode Set permission using Character mode SET permission for a file #chmod u+rwx filename( add permission) #chmod u-rwx filename( remove permission) SET permission for a group name #chmod g+rwx groupname( add permission) #chmod g-rwx groupname( remove permission) SET permission for others #chmod o+rwx filename( add permission) #chmod o-rwx filename( remove permission) Set permission at one time to all #chmod ugo+rwx filename( add permission) Set permission for a file using digit or numbering mode Full control #chmod 777 file name(add permission) #chmod 000 file name(remove permission)
Vim editor Its a text editor. That is upwards compatible to VI. It can use to edit all kinds of plan text.Its specially useful for editing programme.
Syntex:-- #vim option filename
Quit- :q or :q! Without save
To set the GUI and CUI mode #vim /etc/inittab :5 :wq
Switch user one to another account #su username Copy #cp oldfilename newfilename Compare #cmp file1name file2name Provide system memory use #free File system check and repair Command mode Insert mode Exec mode Press I to go to insert mode Escape:- to close insert mode and go to exec mode :wq (save )
#fsck Mount pendrive & CD-Rom #mkdir /media/CD-Rom #mount /dev/cdrom /media/cd-rom #cd /media/cdrom #ls l Unmount cdrom #umount /dev/cdrom /media/cd-rom Mount DVD drive #mkdir /media/DVD-Rom #mount /dev/dvdrom /media/dvd-rom #cd /media/dvdrom #ls l Unmount dvdrom #umount /dev/dvdrom /media/dvd-rom Mount pendrive #mkdir /media/usb #mount /dev/sdb1 /media/usb File system management
Cheak the disk information #fdisk l View the mount partition #df Create the partition and delete the partition #fdisk /dev/sda :m(for help) Create the logical partition
Physical volume Volume group 30mb Karolbagh Logical volume Delhi
Create the linux partition for LVM #fdisk l #fdisk /dev/sda (help for m):m :n :+10M :t : 8 (select any partition ) :8e :w Physical volume create #pvcreate /dev/sda5 /dev/sda6 /dev/sda7 Display the physical volume #pvdisplay Create the volume group #vgcreate karolbagh(groupname) /dev/sda5 /dev/sda6 /dev/sda7 Display the volume group #vgdisplay Create the logical volume #lvcreate L +30M n delhi (logical vol name) karolbagh(group name) Display the logical volume #lvdisplay Format logical volume #mkfs.ext4 /dev/groupname/volume name Remove the volume group
#vgremove /dev/groupname Mounting #mkdir /india #mount /dev/groupname/volumename /india Reduce the logical volume #lvreduce L -10M n /dev/groupname/volume name Extend tne logical volume #lvextend L +10M n /dev/groupname/volume name