Wednesday, April 2, 2014

exec

With the exec command, you can execute a process without forking a new process.
In the following screenshot a Korn shell (ksh) is started and is being replaced with a
bash shell using the exec command. The pid of the bash shell is the same as the pid
of the Korn shell. Exiting the child bash shell will get me back to the parent bash,
not to the Korn shell (which does not exist anymore).

[root@localhost ~]$ echo $$
4224 # PID of bash
[root@localhost ~]$ ksh
$ echo $$ $PPID
5343 4224 # PID of ksh and bash
$ exec bash
[root@localhost ~]$ echo $$ $PPID
5343 4224 # PID of bash and bash
[root@localhost ~]$ exit
exit
[root@localhost ~]$ echo $$
4224

Terminology

Process
A process is compiled source code that is currently running on the system.

PID
All processes have a process id or PID.

PPID
Every process has a parent process (with a PPID). The child process is often started
by the parent process.

init
The init process always has process ID 1. The init process is started by the kernel
itself so technically it does not have a parent process. init serves as a foster parent
for orphaned processes.

kill
When a process stops running, the process dies, when you want a process to die, you
kill it.

daemon
Processes that start at system startup and keep running forever are called daemon
processes or daemons. These daemons never die.

zombie
When a process is killed, but it still shows up on the system, then the process is
referred to as zombie. You cannot kill zombies, because they are already dead.

Monday, March 17, 2014

PERMISSIONS

 permissions on directory and on file

[root@localhost Desktop]# mkdir /india

[root@localhost /]# ls -ld india
drwxr-xr-x. 2 root root 4096 Mar 17 14:13 india

[root@localhost Desktop]# cd /india
[root@localhost india]# ls
[root@localhost india]# whoami
root
[root@localhost india]# touch ap
[root@localhost india]# ls -ld ap
-rw-r--r--. 1 root root 0 Mar 17 14:13 ap

Saturday, March 15, 2014

ADD & REMOVE USERS IN A GROUP

[root@localhost /]# useradd os1
[root@localhost /]# useradd os2
[root@localhost /]# useradd os3

[root@localhost /]# gpasswd -M os1,os2,os3 soft

[root@localhost /]# grep soft /etc/group
soft:x:504:os1,os2,os3

[root@localhost /]# gpasswd -d os1 soft
Removing user os1 from group soft

[root@localhost /]# grep soft /etc/group
soft:x:504:os2,os3

CHANGING THE NAME OF A EXISTING GROUP


[root@localhost /]# groupmod -n soft sales

[root@localhost /]# grep soft  /etc/group
soft:x:504:

ADDING NEW GROUP WITH GID 600 & MODIFYING GROUP GID

to add new group gid

[root@localhost /]# groupadd -g 600 market

[root@localhost /]# grep market  /etc/group
market:x:600:

 modifying group gid

[root@localhost /]# groupmod -g 640 market

[root@localhost /]# grep market  /etc/group
market:x:640:

ADD NEW GROUP

add the group

[root@localhost /]# groupadd sales

to check the group

[root@localhost /]# grep sales /etc/group
sales:x:504: