24-07-2023
KILL
- which transfers or sends signal to the process.
- Then what is process ? A task that your Linux machine is currently working on. Eg., ஒரு browser open பண்றோம் , now Linux creates a PROCESS.
kill -l --> gives list of available signals
kill <pid> --> PID can be taken from the **ps aux** command
kill <pid> <pid> <pid> --> also end multiple pid also in one kill command.
kill -9 <pid>
kill -l 9
kill -l 3
KILLALL
- Same like kill , but here we are passing the program name rather than PID.
- -i can be used for interactive mode.
killall <program_name>
killall chrome
killall -l --> list all the signals which are available.
killall -i <program1> <program2>
PIDOF
- Helps to find the PID of the program.
- But how to get the program name ? [TBD]
pidof chrome
pidof java
NICE & RENICE
- to change the scheduling priority.
- Nice value range (NI): -20 to 19.
- users can only specify values from 1 to 19
- root user can specify the full range of values
- renice will help to resize it.
- '+' are low priority
- '-' high priority
sudo nice -n 5 tar -czf backup.tar.gz ./Documents/*
ps -el | grep htop --> check the nice value , its "ni" ( 4th column )
ps aux | grep sleep
ps -o pid,nice 36323 ( get using PID )
nice -n <number><process name> --> set the priority
nice -10 htop
sudo renice -n 10 -p <PID>
Eg., please provide a sleep process and test ,
below is the output of HTOP,
USERADD
- Used to create the user or update the user.
- always we need to execute this command using sudo.
- each user gets a unique ID (UID) , even that we can choose on our own.
sudo useradd user1 --> this won't create any home directory , it will create only user.
sudo useradd -m user_name --> this creates a home directory
sudo useradd -u 1004 user3
tail -3 /etc/passwd --> to check whether the UID is created
ADDUSER
- This is ask all questions like password , name , etc
PASSWD
- change the user password.
passwd ( just type this , you can change the current user password )
sudo passwd -S user2
sudo passwd -Sa --> all user information
sudo passwd root --> root user can also be change by this way.
USERDEL
- To delete the user.
sudo userdel user4 --> it will delete user but home directory will be there.
sudo userdel -r user3 --> this will delete the home directory also.
sudo userdel -f user_name --> forcefully remove the user
DELUSER
- to remove a user or group from the system.
- only sudo can delete the user.
sudo deluser user4
sudo deluser --remove-home user4
sudo deluser --force user4 --> Even while the user is logged in , it will be deleted forcefully.
GROUPADD
- to create a new group.
sudo groupadd group_name
sudo groupadd <group_name> -g 1234 --> with specific groupid
ADDGROUP
- add group to the system.
sudo addgroup <group_name>
sudo addgroup group_name --gid 6789
GROUPDEL
- to delete the group.
sudo groupdel group_name
DELGROUP
- remove a group from the system
sudo delgroup group_name
GROUPS
- to get the group of the users.
groups <username>
groups
sudo su -
# groups
ID
- print real and effective user and group IDs.
id
id -u testing --> user id it will provide
id -g testing --. group id it will provide
id testing
USERMOD
- it's used to modify a user account.
sudo usermod -aG sudo <user_name> --> add a user to sudo group
sudo usermod -aG group_name user_name --> add group to an existing user
LN
- creates the hard and symbolic links between the files.
cat > sample_file.txt
this is hardlink file.
ln sample_file.txt sample_hardlink.txt --> original file got deleted in some scenario , in that situation we can use the linked file.
ln -s /home/testing/Documents/file.txt softlink_file.txt
--> symbolic or soft link to a file / folder
ln -s file.txt softlink_file.txt
ls -al softlink_file.txt
UNLINK
- call the unlink function to remove the specified file.
unlink filename
unlink dir_name
unlink softlink_file.txt
Important Notes :
control + p --> Previous command.
UID : A UID (user identifier) is a number assigned by Linux to each user on the system. This number is used to identify the user to the system and to determine which system resources the user can access.
Control + d --> come out of the command.
Top comments (0)