This is my first blog post. My main intention to have a blog is that,
It will help me to think about what I wish to write up such that it is understandable by others which implies that I should have understood it at first.
It will enhance my writing skills.
Mainly, It will be a kind of βJournalβing and that it would be nicer to look about what you have done/thought in the past.
stream editor for filtering and transforming text.A stream editor is used to perform basic text transformations on an input stream (a file or input from a pipeline). g β> globally change the content without g it will change only first word. s -> search.
Paste
paste -d "||" state.txt tech.txt | head -n 3
Merge lines of files. Write lines consisting of the sequentially corresponding lines from each FILE, separated by TABs, to standard output.
d β> delimeter , β|β it seperate the two merged files.
stream editor for filtering and transforming text.A stream editor is used to perform basic text transformations on an input stream (a file or input from a pipeline). g β> globally change the content without g it will change only first word. s -> search.
Paste
paste -d "||" state.txt tech.txt | head -n 3
Merge lines of files. Write lines consisting of the sequentially corresponding lines from each FILE, separated by TABs, to standard output.
d β> delimeter , β|β it seperate the two merged files.
This command will display the PID (i.e Process ID) of a particular process. For Eg :- βpidof firefoxβ.
pwdx PID_No
This command will display the path of the process. For Eg :- βpwdx 2074β ==> PID for firefox works on /home/user.
nice -n 11 specific_command
Nice is used to modify programβs priority.Values ranges from [ -20 to +19 ]. -20 has highest priority.Where +19 has lowest priority. -n ==> denotes number. 11 ==> is the value from the range. NOTE : [ From -20 to 0 ] were root user permitted. Value 10 is default.Sudo command must use for set the priority to -20 to 0.
renice -n 7 -p PID_No
Renice is nothing but,to change the priority order.Here PID should mention. This will change the priority from 11 to 7.
BASIC USER MANAGEMENT COMMANDS
Now,we can see some User management commands.
sudo useradd username
This command will add a new user.By default this is password free.We need to set the password later.It will automatically generates User ID.
sudo useradd -u 0127 username
In this command,we made a custom ID (0127) to the username. Conform this by using the below command.
tail /etc/passwd
A user is created named βsampleuserβ with a ID β1002β.
sudo passwd -Sa
Using this command,we can check the password is allocated or not to a user.
P ==> denotes it is Password protected. L ==> denotes for Locked. NP ==> denotes No Password.
sudo passwd username
Here,we can set a password to that user.
There is another method for creating a user with interactive.We can see the method below..,
sudo adduser username
In this method,we can set password,Name,and some user details.
sudo userdel username
For deleting the user,we can use this command. NOTE : This will delete the user,but the folder created for that user wonβt be deleted.The folder will only create when the user create on interactive method.We need to remove that folder manually.
sudo userdel -r username
This will delete the user with the userβs folder. We can check the by changing our directory to home.
cd /home ls
Here, we can see the user folders is created or not.Like the below image.
This command will display the PID (i.e Process ID) of a particular process. For Eg :- βpidof firefoxβ.
pwdx PID_No
This command will display the path of the process. For Eg :- βpwdx 2074β ==> PID for firefox works on /home/user.
nice -n 11 specific_command
Nice is used to modify programβs priority.Values ranges from [ -20 to +19 ]. -20 has highest priority.Where +19 has lowest priority. -n ==> denotes number. 11 ==> is the value from the range. NOTE : [ From -20 to 0 ] were root user permitted. Value 10 is default.Sudo command must use for set the priority to -20 to 0.
renice -n 7 -p PID_No
Renice is nothing but,to change the priority order.Here PID should mention. This will change the priority from 11 to 7.
BASIC USER MANAGEMENT COMMANDS
Now,we can see some User management commands.
sudo useradd username
This command will add a new user.By default this is password free.We need to set the password later.It will automatically generates User ID.
sudo useradd -u 0127 username
In this command,we made a custom ID (0127) to the username. Conform this by using the below command.
tail /etc/passwd
A user is created named βsampleuserβ with a ID β1002β.
sudo passwd -Sa
Using this command,we can check the password is allocated or not to a user.
P ==> denotes it is Password protected. L ==> denotes for Locked. NP ==> denotes No Password.
sudo passwd username
Here,we can set a password to that user.
There is another method for creating a user with interactive.We can see the method below..,
sudo adduser username
In this method,we can set password,Name,and some user details.
sudo userdel username
For deleting the user,we can use this command. NOTE : This will delete the user,but the folder created for that user wonβt be deleted.The folder will only create when the user create on interactive method.We need to remove that folder manually.
sudo userdel -r username
This will delete the user with the userβs folder. We can check the by changing our directory to home.
cd /home ls
Here, we can see the user folders is created or not.Like the below image.
We can see some general commands which should be useful for a new linux user.
jobs
βjobsβ it displays the works which are executed by the current terminal.
jobs -l jobs -p
jobs -l ==> [1]+β3668β Stoppedβ man ls Here,a work has been initiated (i.e man ls).This job was listed. [1] ==> Job ID. 3668 ==> PID stands for Process ID. Stopped ==> This work is currently stopped. NOTE : PID should be any digit,not only six digit.It could a single digit also.
fg %job_ID bg %job_ID
Above commands represents foreground and background process. fg %job_ID (i.e job_ID = 1).It execute the work in foreground. bg %job_ID.It execute the work in background.
runlevel sudo runlevel
Runlevels are predefined operating states or configurations that determine which processes and services are running.It range from 0 β 6. 0 ==> Halt or Shutdown the system. 1 ==> Single-user mode [ used for system maintenance or troubleshooting]. 2 ==> Basic multi-user mode without networking. 3 ==> Full multi-user mode with networking. 4 ==> Not commonly used but can be customized for specific purposes. 5 ==> Full multi-user mode with networking and a graphical user interface. 6 ==> Reboot the system.
init 0 - 6
User can use any oneβof those range mentioned above using init command.
ps
βpsβ displays information about a selection of the active processes.
ps -x ps -A ps aux
ps -x ==> displays the information with PID and STAT. ps -A ==> displays with PID only. ps aux ==> displays every information.both user and root.
ps -ef ps -ef | grep process_name
This shows the system process which is used widely.We can filter the process by using grep.
pstree
It displays the system process in a tree structure.
pstree -p username
-p ==> pass your username or root. It displays the specific users tree structure.
kill -l
To kill a process we can use the command kill. kill -l ==> It lists the KILL Commands.
kill -9 1527 kill -SIGKILL 1527
Letβs assume,a program (Gimp) got stuck while processing.We need to shutdown the program,but it canβt works on GUI.So we need to forcefully kill the process.For that, we need to mention a kill command [ 9 ] to kill the process having a Process ID [ 1527 ] of Gimp.User can also use β-SIGKILLβ instead of β-9β.
NOTE : If we didnβt mention kill number,it will take β15β by default which is a soft kill process. We must enter the PID of that process not name.
killall gimp
Killall will kill the entire gimp program. Here,we can use the name of the program.No need to use the PID.
top top -u username
The top program provides a dynamic real-time view of a running system. It can display system summary information as well as a list of processes or threads currently being managed by the Linux kernel. The types of system summary information shown and the types, order and size of information displayed for processes are all user configurable and that configuration can be made persistent across restarts.
top -u username ==> We can filter it with a specific user.
This is my first and Post#0 on this free blog site. Kaniyam.com and its members have scheduled a series of sessions to learn Linux for everyone and the introduction session starts from 1st February 2024.
On this free WordPress blog site, I have decided to write a blog a day that should have what I learnt for any day.