1)Linux basic commands
2)Linux File permission
3)Cronjob
4)Root user permission
5)Create/Update password
++++++++++++++++++
1)Linux basic commands
1.1)Change directory
$ cd /tmp/playArroundFolder
1.2)List all files and directory
$ ls -lrt
1.3)List specific files
$ ls -lrt testFile.txt
$ ls -lrt test*
$ ls -lrt | grep 'testFile.txt'
$ ls -lrt | grep 'test*'
1.4)View/read file
$ cat testFile.txt
$ view testFile.txt
$ vi testFile.txt
1.5)Read specific line from file using keyword
$ cat testFile.txt | grep '<enter keyword to find>'
1.6)Print last 100 lines from file
$ tail -100f testFile.txt
1.5)Create directory
$ mkdir <directory name>
1.6)Create file
1.6.1)The below command will opens the linux notepad and we can enter our data
$ vi <new file name>
1.6.2)To save the file - follow the bellow steps until '!' symbol click
Press 'esc' button once
press ':' (colon/punctuation symbol)
press 'wq' (It will save and will updated the newly added contents)
(or)
press 'q' (it will save and it will not update the newly added contents)
press '!' (exclamation symbol)
1.7)Edit the file
1.7.1)Delete the content
place cursor and press 'x' button
1.7.2)Add/update the content
place the cursor and pressing 'i' button will activate the insertion mode then we can type any content.
1.8)Remove file
$ rm testFile.txt
1.9)Move file to another location
$ mv testFile.txt /tmp/testFolder/
$ mv testFile.txt /tmp/testFolder/testFile.txt
1.10)Copy file to another location
$ cp testFile.txt /tmp/testFolder/
$ cp testFile.txt /tmp/testFolder/testFile.txt
1.11)Backup the file
$ cp testFile.txt testFile.txt.bk.01May2020
1.12)Content Copy and paste
1.12.1)Content copy
No need to press 'ctrl+c' like windows. Just selecting the content marked as copied.
1.12.2)Paste the content
Mouse right click will paste the copied content
Mouse right click will paste the copied content
1.13)Check disk space
$ bdf
1.14)List all running process
$ ps -ef
1.15)List all running java process
$ ps -ef | grep java
1.16)Know the hostname
$hostname
1.17)Know the parent host
$ ypwhich
1.18)File search in specific location
find . -name filename\*
1.19)Find the specific format files from specific location
find /var -type f -name "*.sh" | grep 'TestScriptFile*'
find /var -type f -name "*.txt" | grep 'TestTextFile*'
1.20)Word search in specific location
find . -type f | xargs grep '<enter keyword to find>'
2)Linux File permission
Permission numbers are:
0 = ---
1 = --x
2 = -w-
3 = -wx
4 = r-
5 = r-x
6 = rw-
7 = rwx
chmod -R 777 test.txt
rwx rwx rwx
chmod -R 555 test.txt
r-x r-x r-x
Permission has separated for 3 user
--- --- --- : rwx rwx rwx
The 1st '---' symbols for root user
The 2nd '---' symbols for system user
The 1st '---' symbols for root user
The 2nd '---' symbols for system user
The 3rd '---' symbols for other user
3)Cronjob
4.1)To list the cron file
cd /usr/sbin
cd /usr/sbin
ls -lrt cron*
-r-xr-xr-x 1 bin bin 152228 Sep 6 2016 cron
4.2)To list the active cron job
crontab -l
4.3)To edit the cron job
$ crontab -e
02 23 * * * <filename>
4)Root user permission
5.1)To open sudo config file
visudo
5.2)To find your or my username/userid from sudo config file
/<userid>
5.3)To add the userid
User_Alias ALCATEL_ROOT=<userid_1>,<user_id_2>
5)Create/Update password
6.1)To check user availability
ypcat passwd | grep <userid>
6.2)To add new user to the NIS
<user id>:<password>:<primary key>:20:<user name>:/home/<user id>:/usr/bin/ksh
Ex: a100::1001:20:Somasundar Kanakaraj:/home/a100:/usr/bin/ksh
Note: Password should be empty while creating user in passwd.nis file
Ex: a100::1001:20:Somasundar Kanakaraj:/home/a100:/usr/bin/ksh
Note: Password should be empty while creating user in passwd.nis file
6.3)To regenerate the passwd.nis file
/var/yp/ypmake PWFILE=/etc/passwd.nis
Note: whatever changes are occurred then we should regenerate this file
6.4)To update the password for specific user
yppasswd <user id>
Ex: yppasswd a100
yppasswd <user id>
Ex: yppasswd a100
Enter new password: Welcome1
Re-enter to confirm the password: Welcome1
/var/yp/ypmake PWFILE=/etc/passwd.nis
ypcat passwd | grep a100
a100:yfE9hiklgfdf-r:1001:20:Somasundar Kanakaraj:/home/a100:/usr/bin/ksh
Note: Password is encrypted automatically
Home page: Click here
Thanks, I hope you enjoyed this session !!!.
-Somasundar Kanakaraj