Process Commands in Unix :
In previous articles i have explained about the unix filter commands as well as file commands in unix.You can look in to unix directory commands also.In this article i will explain the process commands in unix. These process commands are used to filter the data in the file. In this article i will try to explain all the commands related to process with real life exmaples:
- Touch
- PS
- Kill
Touch Command :
If user wants to change the timestamp , or create or modify timestamp Touch command is used. Touch command is used to work with server Operating system timestamp.Following are some important options of Touch command :
Syntax :
$touch [options] Filename….
- -t : This option is used to create a file in specified time
- -r :This option is used to access and modify the time
- -m : This option is used to change the modification time
- -a : This option is used to change access time only
- -c : If file does not exist do not create it.
- -d : This option is used to access and modification time
1.1.Create Empty File / Files:
Syntax :
$touch File1…File2…File N
Touch command is used to create single empty file or multiple empty files.
Example :
$touch Amit Radha
1.2.Change File access time :
Touch command is used to change access and modification time.User can use -a option to change the access time and modification time in touch command.-a option of touch command will set the current date and time to the file.
Syntax :
$touch -a Filename
Example :
$touch -a Radha
The above command will set current date and time to the file named Radha. You can check the file date time modified by using ls command:
LS -ltr
Output :
Radha 03-may-2017 09 : 46 : 45
1.3.Change the modification time :
If user wants to change only modification time of file and access time remains as it is then user needs to use touch command with -m option.
Syntax :
$touch -m Filename
Example :
$touch -m Radha
The above command will change the modification time of file named ‘Radha’.
1.4 . Avoid Creating new file :
To avoid creating a new file if it does not exist user can use -c option of touch command.
Syntax :
$touch -c Filename
Example :
$touch -c Radha
The above command will avoid creating a new file if file ‘Radha’ does not exist.
1.5.Explicitly Set Access and Modification Time :
User can explicitly set access and modification time with specified date format.
Syntax :
$touch -c -t [Format needed] Filename
Example :
$touch -c -t YYDDHHMM Radha
$touch -c -t 17101010 Radha
If you want to see the time format of the same file :
$ls -i
Output:
Radha May 03 10:10
1.6. Use the Format from other file :
User can copy the timestamp format of other file and set it to his own file also by using -r option.
Syntax :
$Touch -r File1 File2
Example :
$Touch -r Amit Radha
The Access time/modification time format of Amit has been assigned to the file named Radha.
2.ps Command :
Process is nothing but program in execution. To manage and to see the active processes on unix operating system ps Process Commands is used. ps basically stands for ‘Process Status’ which is used to display currently running processes in unix operating system. ps command provides the real time view of running processes.
Useful Options of PS Command :
1.-a : This option shows all running processes on terminal with exception of group leaders.
2.-u : This options fetches the information of user and what user is doing.
3.-c : It displays Scheduler data
4.-d : This option displays all processes with exception of session leaders.
5.-f : It displays full listing of processes.
6.-e :It gives the every process running on that terminal
7.-j : It is used to display group id and session ids of the process
8.-l : This option displays long listing
Real Life Exampes with Syntax :
2.1.To Find processes running on to your terminal :
Syntax :
$ ps
Is the command to shows the processes which are running.
Output :
Pid tty time command
2269 3a 0.05 sh
396 3a 0.00 ps
ps is designed to display only the processes that are running at your terminal.
2.2.To Find The other user processes :
Syntax :
$ ps –a
The above command is used to find out which processes are running for the other users who have logged in.
Output:
Pid ppid pgid winpid tty time command
2269 1 147 4444 3a 0.05 sh
396 2 148 7445 3a 0.00 ps
2.3.To see what particular user is doing :
Syntax :
$ ps – u
user1 to see what a particular user is doing. u stands for user and user1 is the username.
Output :
Pid tty time command
2269 3a 0.05 sh
The process in the output is process run by user 1.
2.4. Processes from particular terminal :
Syntax :
$ ps –t
The ps -t the command used to find out the processes that have been launched from a particular terminal.
2.5. To Find out additional process information :
$ ps –f gives additional information about process such as Parent process ID start time, name of process running. The sched is the father of all processes and this gets launched when the machine is booted.
2.6. To know process running at instance:
$ ps –e is the command to know about every process running at that instance.
3.Kill:
$ kill Pid: When invoked kill command sends a termination signal to the process being killed. We can employ sure kill signal to forcibly terminate a process. Signal number for sure kill is 9
Syntax :
$ kill Option
Example :
$ kill -9 2398
Note: System processes like sched and vhand cannot be killed using the sure kill signal.
Click on Topic You want to learn:
- History of SQL
- SQL Create Table(DDL in SQL)
- SQL DML Statements(INSERT,UPDATE,DELETE)
- SQL Select Statement Execution
- Operators in SQL
- Views in SQL
- Materialized View in SQL
- Joins in SQL
- Inner Join / Outer Join
- Full Outer Join / Cartesian Join
- Union and Union ALL
- Intersect and Minus
- Indexing in SQL
- Rank and Dense Rank
- SubQueries and Correlated Subqueries
- Parser and Optimizer
- Oracle 11 G new Features
- SQL Functions List
- Constraints in SQL
- Database Normalization
- Table Partitioning
- Pivot in SQL
- Difference Between Truncate,Delete and drop
- Oracle System Tables
Unix Tutorials :
4.Create File in Unix using multiple ways
12.paste Command
If you like this article on Process Commands or if any suggestion dont forget to comment in comment section.