❌

Normal view

There are new articles available, click to refresh the page.
Before yesterdayMain stream

Format | Head |Tail

By: Elavarasu
22 February 2024 at 14:49
fmt filename

collecting all the words and making it us a paragraph

fmt -u filename

Removing unwanted spaces and making it us a paragraph


Head

head filename
head filename1 filename2

it display first 10 values. because default value is 10

head -q filename filname2

it display first 10 values in each file and name cannot be displayed.


Tail

tail -n 3 filename

It display last 3 values

tail -f filename

it will display realtime values


Numbering

nl filename

It will display the content with numbers and only used for numbering purpose.

nl -s "/" filename

to add a string using -s .


Split

split filename

It will split the content then create new file and it will save the splitted content into the new file.

split -l2 tech.txt split1.txt

It will split the content with two lines then create the new file and saved it into the splitted content.


Tac

 tac filename

it will reverse the content


Last

last 

displays a list of all users logged in (and out) since that file was created.


Translate

tr

Translate, squeeze, and/or delete characters from standard input, writing to standard output.

tr [a-z] [A-Z] < tech.txt | head -n 3 > translated.txt

Sed

sed β€˜s/unix/linux/’ sample1.txt

sed  's/unix/linux/g'  sample1.txt

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.

Format | Head |Tail

By: Elavarasu
22 February 2024 at 14:49
fmt filename

collecting all the words and making it us a paragraph

fmt -u filename

Removing unwanted spaces and making it us a paragraph


Head

head filename
head filename1 filename2

it display first 10 values. because default value is 10

head -q filename filname2

it display first 10 values in each file and name cannot be displayed.


Tail

tail -n 3 filename

It display last 3 values

tail -f filename

it will display realtime values


Numbering

nl filename

It will display the content with numbers and only used for numbering purpose.

nl -s "/" filename

to add a string using -s .


Split

split filename

It will split the content then create new file and it will save the splitted content into the new file.

split -l2 tech.txt split1.txt

It will split the content with two lines then create the new file and saved it into the splitted content.


Tac

 tac filename

it will reverse the content


Last

last 

displays a list of all users logged in (and out) since that file was created.


Translate

tr

Translate, squeeze, and/or delete characters from standard input, writing to standard output.

tr [a-z] [A-Z] < tech.txt | head -n 3 > translated.txt

Sed

sed β€˜s/unix/linux/’ sample1.txt

sed  's/unix/linux/g'  sample1.txt

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.

BASIC LINUX COMMANDS – GENERAL COMMANDS P-2

By: Gowtham G
16 February 2024 at 13:44

Let’s see some general commands once again.

pidof process_name

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.

Now,we can create groups.

sudo groupadd group_name
sudo groupadd -g custom_group_ID group_name

This will create a new group.
Also we can use a custom group_ID.

sudo useradd -G group_name username
sudo usermod -a -G group_name username

Using any one of these commands we can add the respective user to the group.

sudo groupdel group_name

This will delete the group.

That’s it..!

BASIC LINUX COMMANDS – GENERAL COMMANDS P-2

By: Gowtham G
16 February 2024 at 13:44

Let’s see some general commands once again.

pidof process_name

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.

Now,we can create groups.

sudo groupadd group_name
sudo groupadd -g custom_group_ID group_name

This will create a new group.
Also we can use a custom group_ID.

sudo useradd -G group_name username
sudo usermod -a -G group_name username

Using any one of these commands we can add the respective user to the group.

sudo groupdel group_name

This will delete the group.

That’s it..!

Basic Linux Commands -GENERAL COMMANDS

By: Gowtham G
15 February 2024 at 03:32

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.

That’s it…!

Intro to GNU/Linux

31 January 2024 at 17:11

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.

Wish me good luck!

❌
❌