You are on page 1of 6

15/02/2022 Linux(Red HAT )

default shell of linux /bin/bash


regular user:$
super user:#
bash similar cmd.exe
new terminal : ctrl+shift+t

Shell basics:
cmd option argument
useradd -u 2001 user01

Terminal
also known as console
physical console (TTY):teletype
virtual console (PTS): Pseudo terminal slave
ctrl+alt+(F1-F6): terminal
TTY1: Welcome screeen
TTY2: graphical
TTY3-6: CLI

Gui:PTS1-6

Terminal
alt+f2
gnome-terminal
for passing comment "#"
for opening new terminal in terminal: ctrl+shift+T
for inreasing font size:left sided ctrl+shift++
for decreasing font: ctrl+alt or shift+-
TTY
for finding username : whoami
who (user with TTY)
w (for more detailed info)

for switching terminal


chvt 1-login
chvt 2-graphical
chvt 3-6:cli

[root@localhost ~] : local user and fqdn

su - root /local user name (for switching user)


ctrl+l (for clearing screen)
cd (for changing dir)
for views in folder : ls , ll , ls-l
for making new user: useradd Arka or adduser Arka
for adding user password: passwd username

pwd : for print working dir


cd ~ : for going to users working dir

to create dir
mkdir: to create dir : mkdir a/b/c/d -pv
mkdir a, mkdir b : for creating seperate folders
mkdir foldername -pv: to make sub dir [p: parrent dir , v :vervos (used for
showing execution cmd report)]
rmdir : for removing blank dir
rm -rvf *: for removing all files
rm -rvf filename:[recursive vervos forcefully] for deleting all files subfiles.
**mkdir MCC; cd MCC ; mkdir SEM 1 SEM 2:
tree MCC/

**history
![command number]

for creating files : cat [for creating or reading ], vim, gedit, echo [for
appending files] ,

**cat> file1.txt
**cat>>file1.txt [>> for adding lines]
welcome to jetking!
ctrl+d[for saving files]
for checking graphically gedit file1.txt
for checking files cat file1.txt
touch filename : create blank file and change timestamp of any files and folder

**echo
echo "text line ">file1.txt[> for replacing lines and >> for adding lines]

for loging in to other user without changing shell: su username


exit : cmd should be used instead of logout/ctrl+d

/bin/bash: echo #SHELL [to print shell]


/usr /bin/bash : echo #BASH [to print bash]

for sys restart:


init 6 , reboot

for sys power of :


init 0, poweroff

cd .. : one step back


cd ../../.. : 3 steps

**etc : configuration dir


**User info =/etc/passwd
**vim/etc/passwd : esc+shift+ :q!
**head : to view 1st 10 lines
**tail : to view 10 last lines
**pipeline : cat/etc/passwd |
[for making output as input for 2nd cmd]

****pipeline : cat /etc/passwd | grep Arka


[for finding exact info from 1st output]
******pipeline : cat /etc/passwd | tail/head -n 3
[for showing starting 3 lines ]

16/02/2022

********echo "redhat" | passwd u1 --stdin [another method for seting passwd]


********useradd u2 ; echo "redhat" | passwd u2 --stdin [another method for seting
passwd]
****wc filename.txt [word count]
wc -l/w/c [line/word/char]
**man [date/command] to find out about that command
**date +%[r/R]
-----------------------------------------------------------------------------------
--------------------------------------------------Chapter 3/67
**sbin : super user command
*bin : local user executable command
*cd /
ll
**"l":for linked files
**"d": for directory files
*/usr : installed soft, shared lib
/usr/local :locally customized soft
/usr/bin : user commands

*/var : printer pool or website contents


*/run: last boot runtime data
/var/run
*/tmp : temp files stored for 30 days
/usr/tmp: normal tmp dir : 10 days after history deletes
/var/tmp : another tmp dir : 30 days after history deletes
*/boot : boot files
*/dev: device files

*ls -[a/R]: to show hidden files/ recursively


"./.." : current/parent working dir for hidden files

--------------------------------------pg 64

*for copying files in dir :


cp test.txt [A/dir name ]
cp /root/Desktop/test.txt /root/Desktop/B : for copying files from 1 to next
dir with diff path
touch /root/Desktop/test.txt : for making files in diff dir
* ls -l /root/desktop/ : for showing files from root or any other
*mkdir Folder {1..10} : for making 10 folders in a folder
* for copying a folder into another folder
cp -r A C : from that dir
cp -r /root/Desktop/A /root/Desktop/FD : from any dir

*For Moving/ Re-naming:


mv abc.txt acd.txt : for re naming
mv abc.txt [Filename] : for moving

*hostname/hostnamectl/hostnamectl status : for checking host status


*for renaming hostname : hostname [name] [for tmp change]
bash
**for permanent changes : hostnamectl set-hostname [name ]
init 6 [for reboot after changes]
-----------------------------------------------------------------------------------
---------------------------pg 75
*Hardlinks and softlinks: denoted by ln and ls:
**for creating hardlink : ln [filename].txt /path/filename_hlink2.txt
=>ln mcc/a/file2.txt mcc/b/file2copy.txt
[1st and 2nd copy both linked, changes occurs
in both if any, if copy is deleted no changes occurs to parrent file]
**for creating softcopy : ln -i [gives unique inode number]
ln -s
*at [time] [for executing command at a specific time]
init 6
-----------------------------------------------------------------------------------
--------------------------------

17/02/2022 Chapter 4

* -k [keyword ]
man -k mkdir
*updatedb [for updating database for help]
mandb
what is mkdir

man mkdir 1p

* info [all commands info]


*df [disk usage]
*fdisk -l [gives disk info]
*pinfo [for selecting commands and getiing info about that]
*tar [for archieving/reducing file space]

*man useradd -------------------------pg 132/112


/cp
["/string" used for highlighting that command in whole man info ]

* .gz [is a zipped file extension ]


* for writing one file content into other
cat /etc/passwd > userlist.ps

* cat /etc/passwd | less/more [limited info displayed and asks us to quit or


not /more and quits automatically at contents end ]

* cat /etc/passwd | grep bash > user.txt


*ls -l *a/a*/*a* [patern matching exact/starting with /having that file or
charecter]

CHAPTER :-5 VIM


EDITOR------------------------------------------------------------------

root@JAVED ~]# vim


vim vimdiff vimtutor
[root@JAVED ~]# vimtutor (For Help Regarding VIM)
[root@JAVED ~]# vim Parwez.txt
1 i insert Mode
2 Command Line
3 This is a Text editor
4 it is used to Edit the Files
5 --------------------------------
6 Extended Command line mode (ESC)
7 :w Save
8 :q quit
9 :! forcefully
10 :wq! save quit forcefully
11 yy copy
12 2yy copy 2 line
13 dd Delete a line
14 2dd Delete 2 lines
15 cc cut
16 5cc cut 5 lines
17 p Paste
18 u undo
19 CRTL+r redu
20 gg (Go to Start of file)
21 Shift+g / G (Go to End of the file)
22 File line Show :set number :se nu
23 File line Remove :set nonumber :se nonu
24 :21 To Go on the Specific line
25 0 Start of the Line (Home Button)
26 $ End of the line (End Button)
27 --------------------------------------
28 Extended Command line mode (ESC)
29 ESC Button Press to Go in Command line mode
:wq!
-----------------------------------------------------------------------------------
---------------------------------
18/02/2022 Chapter 6

*super ,sys, regular user


*daemon : for running users
*for checking any users id : ip [username]
*ls -ld [file name ]
[list directory]
*ps -au
[all user id ]
* cat /etc/group [fir checking grp ids]
*Username for the user : User pass format stored in /etc/shadow [in encrypted
format] : UID : GID : Real name of usename [or comment] : User home directory
location : Grp info location

*grp id info / fields :-


grp name : pass format: gid : user lists
Primary groups
Supplimentary groups

* UID range s
0 reserved for root user
1-200 reserved for sys users assigned to sys process statically
201-999 reserved for sys users assigned to sys processdynamically
1000+ reserved for regular users
*useradd/mod/del

**for changing shell


usermod -s /sbin/no login [username ]
[s- for shell]
usermod -s /bin/bash [username ]

**for changing home dir location


cat /etc/passwd | grep username
mkdir /Database
usermod -d /Database/username username
[for changing dir ]
usermod -m -d /Database/username username
[moving and changing dir]

*for changing comments/ secondary name / display name :


usermode -c "abc system admin" username

*for changing gid :


groupadd -g 8000 Account
cat /etc/group | grep Account

*for terminating a process


ps -ao pid
kill -u [process id ]

You might also like