Unix Add and Delete, Memory and Partition Information

In this article you will learn about how to add and delete user in Linux operation system, how to get memory information and partition information.

Unix and Linux Commands
First login as root user and practice following commands. It is also recommended to create another user and practice on the dummy user.

login as: root
[email protected]'s password:
Last login: Wed Sep 26 17:35:40 2012 from gur-hello.com

This command will list out all directory and files.

[root@VM-TEST ~]# ls
anaconda-ks.cfg  Downloads           Music     sample-vsftpd.conf
Desktop          install.log         Pictures  Templates
Documents        install.log.syslog  Public    Videos

[root@VM-TEST ~]# ls Desktop/
amit  anil

[root@VM-TEST ~]# cd Desktop/

[root@VM-TEST Desktop]# ls
amit  anil

You can  use vi command on a file, type vi file name. If the file file name already exists then the first page of the file will be displayed; if the file does not exist then an empty file will be created into which you may write anything.

[root@VM-TEST Desktop]# vi sample (here sample is a file name)
Anil kumar

Now enter anything in this file and save using following option.

1.    Press ESC and type :wq! Enter
2.    Press ESC and press Shift+z+z (2 times z with shift)
3.    Press ESC and type :q! Enter (For without saving)

cat command is used to show the content of a file.

[root@VM-TEST Desktop]# cat sample
Anil kumar

fdisk command with -l option will show you partition information of Linux OS.

[root@VM-TEST Desktop]# fdisk -l

Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000a7dcc

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          66      524288   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              66         327     2097152   83  Linux
Partition 2 does not end on cylinder boundary.
/dev/sda3             327         523     1572864   82  Linux swap / Solaris
Partition 3 does not end on cylinder boundary.
/dev/sda4             523        1306     6290432    5  Extended
/dev/sda5             523         588      524288   83  Linux
/dev/sda6             588        1306     5764096   83  Linux

df command with -h option will show you partition info, mounting and space.

[root@VM-TEST Desktop]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda6             5.5G  3.2G  2.0G  62% /
tmpfs                 504M  272K  504M   1% /dev/shm
/dev/sda1             504M   37M  442M   8% /boot
/dev/sda2             2.0G   67M  1.9G   4% /home
/dev/sda5             504M   17M  462M   4% /tmp

How to add and delete users in Linux operating system?

Following command will help you to add users in Linux OS.

[root@VM-TEST ~]# useradd amit
[root@VM-TEST ~]# useradd anil

[root@VM-TEST ~]# ls /home/
amit  anil  lost+found

Usage: userdel [options] LOGIN

-f, --force                   force removal of files,
even if not owned by user
-h, --help                    display this help message and exit
-r, --remove                  remove home directory and mail spool
-Z, --selinux-user            remove SELinux user from SELinux user mapping

Note down the difference between simple userdel and userdel with options

[root@VM-TEST ~]# userdel anil

[root@VM-TEST ~]# ls /home/
amit  anil  lost+found

[root@VM-TEST ~]# userdel -r amit

[root@VM-TEST ~]# ls /home/
anil  lost+found

That’s it..

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top
Scroll to Top