You are on page 1of 34

LINUX BASIC COMMANDS

TO CREATE A DIRECTORY: : mkdir dirname

TO CREATE A FILE: : cat > file name (ctrl+d to save)

TO CREATE A NANO FILE: : nano filename (ctrl+w to search) (ctrl+r to replace) (ctrl+x, y, enter to save)

VI EDITOR: : vi filename ( I to insert) (ESC, :, X to save and exit from the current file) (ESC, :, W to save the file without existing from it) (Q to quit the current process) (H to left side, L to right side, J down side, K up side) (ESC, :, Q, ! this command is used when error is occurred) (ESC, DD is used to delete any of the line written on vi files) (ESC, YY is used to copy the lines. P is used to paste the copied lines) (VIM to see the vi improved mode) (:help to view the help mode fo the vi editor)

SOURCE DIRECTORY OF THE PASSWORD: : vi /etc/passwd

MDS PASSWORD ENCRYPTION: : vi /etc/shadow

SHOWS DETAILS OF USERS AND GROUPS: : vi /etc/group

HOME DETAILS: : dir /home

DELETING THE FILES: : rm filename

DELETING THE DIRECTORIES: : rm r dirname

DELETES THE DIRECTORY FORCEFULLY: : rm rf dirname

CREATES A FILE IN ZERO BYTES: : touch

TEXT EDITOR TO CREATE AND EDIT FILES: : gedit

SORT LINES OF TEXT FILES: : sort filename

PRINT THE NUMBER OF NEWLINES, WORDS, AND BYTES IN FILES: : wc filename

CONCATENATE FILES AND PRINT ON THE STANDARD OUTPUT : cat n filename which is created in any editor.

PRINTS RECENTLY USED COMMANDS : history

SHOWS FILES AND DIRECTORIES: : ls

SHOWS LONG LISTINGS OF FILES AND DIRECTORIES: : ls l

SHOWS THE HIDDEN FILES AND FOLDERS: : ls a

SWAPPING BETWEEN TWO DIRECTORIES: : cd ..

TO ENTER DIRECTLY TO THE FOURTH DIRECTORY: : cd first/second/third/fourth

TO CREATE A USER : useradd username

ADD A PASSWORD TO THE USER: : passwd username

LOGOUT FROM THE USER: : logout or ctrl+d

TO VIEW THE LOGON TIME OF ALL THE USERS: : who

SHOWS THE DETAILS OF ALL THE USERS: : whoami

SWITCH BETWEEN THE TWO USERS: : su - username

SHOWS THE MANUAL OF ALL THE COMMANDS: : man (cmd name) /

SHOWS THE PRESENT WORKING OR USER DIRECTORY: : pwd

TO FIND OR LOCATE A FILE: : locate (file or folder name)

TO COPY FILE OR FOLDER: : cp filename dirname

TO MOVE FILE OR FOLDER: :


mv filename dirname

RPM (RED HAT PACKAGE MANAGEMENT) :


rpm [operations] [options] [packages name]

Operations: -i (installs), -U (update), -q (query), -e (uninstall). Options: --force (forcefully overwriting of other packages , --nodeps (force the RPM to do the installation).

Eg:

rpm ivh packagename.rpm

USER ADMINISTRATION IN LINUX

ADDING A USER:
useradd username (after creating the user here two files were modified /etc/passwd & /etc/shadow file). passwd username (adds the passwd to the user).

Cat /etc/passwd (This command will show you the detailed user information)

Eg: username:password(x):userid(500):groupid(500): comment:users home dir(/home):default shell for user (/bin/bash)

TO SEE MAN USERADD PAGE:


man useradd

ADDING A USER WITH A COMMENT INBETWEEN:


useradd c comment username

CHANGING COMMENT OF A USER:


man usermod c new comment existing username

REMOVING A USER COMPLETELY FROM THE SYSTEM:


userdel rf username

CREATING A SINGLE PASSWORD FOR ALL THE USERS IN THE SYSTEM:


vi filename

i username:password username2:password username3:password username4:password

save it (Esc,:,wq or x) #chpasswd < filename (This cmd will change the password) #rm filename (This is to delete the used file)

CHANGE THE NAME OF THE USER :


usermod -l login-name old-name

GROUP DETAILS:
cat /etc/group

eg: Groupname: Password(X): Group ID Number(501):

cat /etc/gshadow cd /home (back to the home directory) cd username (into the user directory) ls al (shows the list of the files under the particular user also known as the owner of the

files) drwxrwxrex(permissions): linux6 (username): cmc (groupname)

ADDING A GROUP

groupadd groupname

ADDING A GROUP UNDER THE SYSTEM RESERVED CATEGORY (Under 500):


groupadd r groupname (-r is to register the group under the 500 category)

ADDING USERS TO THE GROUP:


usermod G groupname username

To add a user to group use following command: # useradd -g groupname username # id tony

VIEWING THE USER IN THE LISTING MEMBER OF THE MENTIONED GROUP:


cat /etc/group

CHANGING THE GROUP NAME


groupmod -n new_group_name old_group_name

ADDING A USER IN FOUR OF THE GROUP GIVEN BELOW: # useradd -G group1,group2,group3,group4 username

CHANGING THE FILE PERMISSION: U is denoted as owner. G is denoted as group. O is denoted as other.

R W X

= = =

Read Write Execute

= = =

4 2 1

THE HIGEST PERMISSION ON A DIRECTORY IS 755. U=7 G=5 O=5

THE HIGEST PERMISSION ON A FILE IS 644. U=6 G=4 O=4

Symbolic Format: ADDING WRITE PERMISSION TO THE GROUP:


chmod g+w filename (g indicates group and w indicates write)

ADDING READ WRITE PERMISSION TO THE GROUP:


chmod g+rw filename

REMOVING THE READ WRITE PERMISSION FROM THE GROUP:


chmod g-rw filename

SETTING PERMISSIONS WITH AN EQUAL SIGN: The equal sign permission that we specify are set but the other existing permissions are erased.
chmod ug=rw filename (The user and the group will have both the read and write access).

Binary Number or Raw Format:


chmod 754 filename (This cmd specifies the full permission to the owner, read and write

permission to the group and only read permission in others) TO ENSURE THE GIVEN PERMISSION:
ls d filename

CHANGING THE NAME OF THE OWNER FROM A TO B: :


chmod A B

CHANGING THE NAME OF THE GROUP: :


chgrp C D

DIRECTORY MODES:

r w x (means the full access to the directory) r _ x (means limited access as you can enter the directory but cannot write or modify in it) _ _ _ (means no access)

CHANGING THE OWNER OF THE FILES AND DIRECTORIES:


chown username newgroupname file/foldername

MAKING A NEW DIRECTORY REGISTERED WITH THE EXISTING GROUPNAME:

#newgrp groupname #mkdir dirname #ls l (view the directory in which group)

APPLYING ADMINISTRATOR PRIVILEDGES TO A NORMAL USER OF A GROUP:


gpasswd A username groupname (This command makes a normal user an administrator) gpasswd a username groupname (This command will take the other user under the group

of the newly created administrator)


gpasswd d username groupname (This cmd will delete the user from the currently created

group)
cat /etc/group (This command will show the user and group details).

GROUP ADMINISTRATOR IN COMBINATION WITH USER PRIVATE GROUPS:


gpasswd A username username (This user can add and delete from it own user private

Group)

gpasswd a another.user.name admin.username chmod o-r dir.name (This is to make the directory only readable to the others owner)

FILE SYSTEMS RELATED COMMANDS

MOUNTING CDROM: #mount l (mounted devices details)

#df h #pwd

(human readable format disk details) (present working directory)

#mount t iso9660 /dev/sr0 /home/linux6/Desktop/dir name (mounting cdrom)

#fdisk l ( Lists all the disk in your system and all those partitions on those disks. The first partition having the * sign is the boot partition. The 2nd partition would be the main linux partition, this is where the user files and log files are located. The 3rd partition would be the swap partition. It is used when your main memory fills up.)

PARTITIONING HARDDISK IN RED HAT LINUX: #fdisk /dev/sda #m (This letter is typed for listing the menu of cmds. Mkfs is used to build a linux file system. Equavalently its equal to format a disk when you make a file system in a disk). #v #d #p #n #p #2 (This cmd is used for the number of free size of redhat linux). (This cmd is for deleting partition) (This cmd is used for viewing the partition in linux) (This cmd is used for the help to partition the hard drive +100M) (For creating a primary partition) (choosing the number for a new partition)

#Enter(Press enter for default cylinder selection) #+50M(Partition size in megabytes) #w (This cmd is used after partitioning the hard disk. As this cmd save the hdd configuration) #partprobe

(This cmd is used for continuing the program without doing reboot after the hard disk partitioning. #fdisk l (This cmd is used for showing all the partitions of the HDD) #mke2fs j /dev/sda2 (This cmd formats the partion. Mk=make, e2=extension2, fs=filesystem). #First make a directory then mount the new partition of the HDD by the following given cmd. #mkdir directory name #mount /dev/sda11 /directory name #vi /etc/fstab (It is used for linking the directory with the mounted partition and it is must, dev/sdall 1data ext3 defaults 00

#fsck /dev/sda(2or3or4) (This cmd checks the file system for errors. Never ever run this command in the mounted partition, specially when its mounted on write only mode.)

#df (The df cmd displays information on file systems. How much space is being used, how much available and so on.) #df h (displays the information on file system in human readable format.) #du (displays information about every single sub directory on the whole system below where youre starting with.) #umask S ( youll see what your default permissions are and for most linux systems rwxr_xr_x, some might have _rwxr_x_ _ _. So you can set umask S in the

/etc/profile file.)

SUID PERMISSION (SECURITY) #cd /etc/shadow (This is the file where peoples encrypted passwords are stored. There you can view the $0$000000(eg), actually the password starts from the 000000. #ls l /etc/shadow (here you can view those permissions _r_ _ _ _ _ _ _ _ _, here you can see only the root has the permission to read and no other permission for anybody in the system. #su username (to switch user) #passwd (for changing users own password) #su (again switch to the root user) #cat /etc/shadow (for viewing the changed password encryption) #ls l /usr/bin/passwd ( here is the password cmd located. First you can see that everybody can executed this file in the system. Everybody can run this file. Root can read this file also S this file. S means it has set ID permissions. So when a normal user runs this file at some instant in the program when they need to write to this file to change the encrypted version of the file password they are setting the user ID to be the UID of the file (userID), which is root. So if youve got some kind of backdoor setuser ID then you probably have to remove it without hesitation, if you think that you havent installed the particular program.

ADMINISTRATION OF NETWORK IN LINUX


#cd /etc/sysconfig/network-scripts/ #cat ifcfg-eth0 #system-config-network (To open the network configuration interface) -select device configuration -select eth0

-select Ethernet -uncheck the star (*) from Use DHCP -type down IP address and all the information which is mandatory for filling up. #ifconfig eth0 up 192.168.1.1 netmask 255.255.255.0 (To start the network service configuration) #route add default gw 192.168.1.1 (This cmd is used to add the default gate address and starts it) #cat/etc/resolv.conf (This cmd is used for the name server)

LINUX ESSENTIALS
SHELL SCRIPTS: #vi example1.sh I #!/bin/bash (This is the path of the shell that youre going to use. Bash is the most common language and the most common scripting language in linux.) #!/bin/sh (This is the path which is occasionally seen. But /bin/sh is linked to /bin/bash in the system.)

# echo Deep

(Any of the line which start with only with the hash # then we call it as a comment.) (It is used to print out the statement which is written in between the double quotes in the screen.)

Esc,:,x or wq (To save the file.)

#bash example1.sh #./example.sh

(It is used to execute the program.) (It is a common way to run the program. This works if youre working in the current directory)

#sh example.sh

(This is also used to execute the program.)

SCRIPTS USING VARIABLES: Variables are of datas and information and there are two types of variables in some sense.

1) First kind of variable is passed into the program when you run it.
#!/bin/bash echo Hello $ 1 #This cmd will represent the name and this echo statement will printout Hello Username.

2) Another kind of variable is called local variables.


Number1=20 Number2=40 #If you want to add these things up and store them in the Number 3 then you have to use the let command. Let Number3=$Number1+$Number2 #The reason to use the dollar sign on the above cmd is because you want the value of the variable substituted into this expression. #Now, if you want to print out the value of Number3 to the screen then you have to mention in the exho statement. Echo The answer is $Number3 #sh example2.sh username

SCRIPTS USING CONDITIONAL STATEMENT: #!/bin/bash If [ $# -lt 1 ] #This line signifies the conditional expression. If this expression is determined to be true then all the stuff in between then and fi is executed. If the expression is determined to be false then all those stuff in between the then and the fi skipped and will perform the rest of the stuff which is below the then fi statement.

#If the number of arguments is less than 1, I will say you have to pass at least 1 argument to the script and then I say exit. The exit statement just stops running as it exists out of the

program, it doesnt execute any more lines of code, its just finished. Now, if the number of arguments is not less than 1 then it skips the then and fi statement and it goes to cd /home/$1.

#[ ] square brackets are important in the condition expression and the cmds inside the brackets is followed after the space and ends with before the space in between the square brackets.

# As $1 represents the first argument passed into our shell scripts. Here $# says how many arguments are passed into our shell scripts.

#lt, this is known as the less than operator.

#[ $# -lt 1 ], so this says, if the number of arguments is passed into our shell script is less than 1 then it will execute the cmd written in between the then and fi cmd.

then echo you must pass at least one username to the $0 script #Here the $0 is another special variable and thats the name of the script. Eg $1 is the first argument, $2 is the next argument, $# is the number of arguments and $0 is the name of the script.

$0 script Exit Fi cd /home/$1

space=`du s | cut f 1`

#Space is a variable and is equal to du s. remember when you use du s cmd then there are two fields displayed. First, is the number of bytes and the second would be the name of the directory.

#Here, I am doing du s but I am piping | into this new command called cut. Cut command is used to cut the piece or thing that is being piped into and the minus -f 1 says cut off the first field to display that, dont display 2,3 or 4. How many fields there are, just show the first field.

#So, when we execute the cmd it will show only the number of bytes part but not the directory.

echo $1 is using space kilobytes

#In this echo statement, I am going to say $1 that user that I cd into the /home directory, that user is using Space kilobytes.

#sh example3.sh username

SCRIPT USING WHILE LOOP: #!/bin/bash If [ $# -lt 1 ] Then Echo you must pass at least one username to the $0 script Exit fi while [ $# -ge 1 ]

do cd /home/$1 space=`du s | cut f 1` echo $1 is using $space kilobytes shift #The shift cmd takes the argument and moves them over, so $2 becomes $1, $3 becomes $2 and so on and $1 is moves into oblivion and is lost.

done

sh example4.sh username1 username2 username3 sh example 4.sh

This is a looping mechanism like the if statement was the conditional mechanism then the while loop is like the if statement and it starts with the conditional expression while [ $# -ge 1 ] and if the given expression is true then everything in between do and done is executed. If the while loop is false then all of the do and done is skipped and we move on. Its just like the if statement the only difference is, if all the while loop is true then all the given between do and done and when it gets end then we again go back to the top at the while loop and we test this again and if its still true then we do all the stuff again. It will do until it gets false. Finally when its false then we will skip out and do the rest of the code. If the while loop statement is always true then you will never end up because it will do the while loop again and again, and you dont want that because it will hung up all the resources, for that problem you have to kill processs to stop that. So you have to make sure that this condition [ $# -ge 1 ] will eventually false and the shift cmd will make it false. Shift cmd takes all the arguments like $1, $2, $3 etc. it takes all the arguments and shifts on one over, thats why its called shift. After the shift cmd executes $2 becomes $1, $3 becomes $2 and so on. But $1 is moved over and its lost.. so if, you need to use the $1 later in this program the shift cmd would not be the way to go because you would loose it. So here if you dont want to use the $1 again then the shift cmd is perfect.

LILO (LINUX LOADER) OR GRUB (GRAND UNIFIED BOOT LOADER): When you power up your computer, the first thing that happens is the BIOS starts (Basic Input Output System).

This goes around and probes some hardware. It checks to make sure your memory timing is correct and your devices are plugged in. After passing the test of hardwares then the BIOS goes to the Master Boot Record on your disk. The BIOS knows where the master boot record is and it looks for the boot loader in the Master Boot record. One of the boot loader that could be there is LILO and we can look up the configuration file for LILO or GRUB. #cat /etc/lilo.conf.anaconda #cat /etc/lilo.conf #cat /etc/grub.conf or or

FILE SHARING: When we share a file from a linux machine to the windows machine then we use a program called samba, its acronym is SMB describing the windows file system. As SMB stands for Server Message Block. If you are sharing the files between the linux systems or with the unix systems then you need to use a tool called NFS Network File System.

SHARING FILES FROM WINDOWS MACHINE TO LINUX :

1. WINDOWS CONFIGURATION:
-Open up windows machine -Create a new folder and share it.

2. LINUX CONFIGURATION:
-smbclient //192.168.1.1/folder name U xpusername -xp password -ls (To view the file) -help (For the cmds) -get filename (To copy the file from the windows machine to linux machine) -quit -ls (You can view that copied file in your system).

ACCESSING THE WINDOWS SHARED FOLDER IN LINUX MACHINE:

1. WINDOWS CONFIGURATION:
-Create a new folder and share it.

2. LINUX CONFIGURATION:
-smbmount //192.168.1.1/shared foldername linuxfolder/ -password -go into the empty linux folder -ls (Here you can view the files of the window OS). -smbumount linuxfolder/ (This cmd will unmount the windows folder in the linux machine).

CONFIGURATION FILES AND RELATED TOPICS 1) User configuration files are .files. 2) System configuration files resides in /etc/ Eg: #cd /home/linux6 #ls a (To list up the hidden files in the directory)

STARTUP SCRIPTS DETAILS (RUNLEVEL) #root #passwd #cd /etc #ls #cd rc.d #ls

Dont ever mess with the rc.sysinit script because that all scripts depends upon something in the system script. You can add some script then add it to your rc.local script. #more rc.local (Here you will see that all of your local script is executed after all the other init scripts).

RUNLEVELS: There are different run levels from 0 to 6. Each run level represents sort of a different state of the system. 0, 1, 2, 3, 4, 5 & 6. #ls rc1.d (You can see two types of files, k and s type. k is for killing the process and s is for starting the process. You can also manually change the file permission to k to kill and s to start the services.

#more /etc/inittab (Its another piece of whole startup puzzle. There you can see all the descriptions of all the run levels including the present working run level. For changing the run level permanently type the number on the last line where the default run level is mentioned.

#vi /etc/inittab (changing the run level permanently) #telinit 2 (any run level number for temporary use) #shutdown (to be back in the previous run level)

STOPPING AND STARTING A PARTICULAR SERVICE #cd /etc/init.d #ls # /etc/init.d/netfs stop # /etc/init.d/netfs start # ./netfs start (here you can see the services) (stops the service) (1st way to start the service) (2nd way to start the service)

#./netfs restart

(3rd way to start the service)

MAINTENANCE OF A LINUX SYSTEM BACKING UP YOUR SYSTEM: Here we are using tar (Tape Archive) to wrap up all the files and directory to bind in. #su (Super User or Switch User)

#tar - -create - -verbose - -same-permissions - -file /desired-directory/new-filename /home /etc (This cmd backup the files and directories to the alternative media). --create --verbose --same-permissions (For creating a new tar file). (It will tell you the errors that are coming up the files that are getting on to the tar files and so on). (It just maintains the permissions in the directories that are copied into the tar file). --file (It just creates a file)

/desired-dir/filename (This cmd creates a new directory named newfilename) /home /etc (The home and the etc directory are gonna be backup)

#tar cvpf /desired-directory/new-filename /home /etc (This cmd is the short hand and is on the contrary to the previous cmd).

#tar cvpf /desired-directory/new-filename2 - -newer 20may02 /home /etc (This cmd will backup the directories and the files from the date mentioned above [differential or incremental backup]).

RESTORING FILES FROM THE MEDIA: #cd / (This cmd is recommended). #tar xvpf /desired-directory/backedup-filename home/perry/filename (This cmd is to backup the particular file from the media). X V P F (This is for extract). (Verbose) (Permissions) (File)

home/perry/filename (This cmd is for the restore path) #tar tvpf /desired-directory/backedup-filename | more (This cmd will list you the details of the exact name of the file paths).

MONITORING MEMORY SPACE: #free (This cmd will run the free monitoring in every 3 seconds). #free s 5 > free_output (This cmd will take the monitoring output int the output file and there you can monitor all the system usage information). #df (This cmd si also the counter part of the free cmd. It tells you the amount of disk space).

ADVANCED COMMANDS

TO RESTART THE COMPUTER: : init 6 or reboot

TO TURN OFF THE COMPUTER: : init 0 or poweroff

XXXXX-XXXXX-XXXXX-XXXXX-XXXXX

INTERMIDIATE AND ADVANCED


LOGICAL VOLUME MANAGEMENT (LVM): LVM allows you to manage partitions. PV LVM TERMS & CONCEPTS:
2G B 4G B

PV- (Physical Volume): PV is known as a hard disk. If youve got multiple HDD in your system then it will be known as multiple PV. LVM 6GB-100MB

LVG-(Logical Volume Group): It is a total storage space made by multiple HDD or PV. LV LV- (Logical Volumes): These are the volumes or the partitions which are taken from the LVG. The advantage is that you can add free space to those partitions which are really in need of additional space. /home / swap
free space

AFTER INSTALLATION: #info LVM #Lvextend L +100 /dev/volume00/logvol00 Lvextend +100 Volume00 Logvol00 Extends the Logical volume space. 100MB size extension Volume Group Name Lovical Volume Name

COMMAND LINE INTERFACE LVM CREATION:

#fdisk /dev/sdb (This is the added HDD)

CREATING EXTENDED PARTITION: #p

(This cmd is used for viewing the partition in linux) (This cmd is used for creating a new partition) (This is for selecting extended partition) (This is to make the partition 1)
-

#n #e #1

hit Enter to select the default value of cylinders again hit Enter to use all the cylinders space for the extended partition (This cmd again shows the partition created)

#p

CREATING LOGICAL PARTITION: (3 PART) #n #l


-

(again creating a new partition under the extended partition) (This is for the logical partition) hit Enter for the default value of cylinders. Enter the partition value +100 (This cmd again shows the partition created) (for changing the partition system)

#p #t

type down the which you want to change to the partition type. (This cmd is used to type the partition codes)

#l
-

type 8e for the Linux LVM (Here you can see that linux partition is now LVM partition) (This cmd is used to write changes)

#p #w

CREATING LVM PV(Physical Volume): (3 PART) #fdisk l /dev/sdb #pvcreate /dev/sdb5 CREATING LVM VOLUME GROUP: (2 PART) #pvs (Show the Physical Volume which are not attached to any volume group)

#vgcreate vg1 /dev/sdb5 (eg:/dev/sdb6) Vg1 #vgs Its the volume group name mentioned by me. (shows the volume group)

CREATING A LOGICAL VOLUME IN THE LVM VOLUME GROUP: #lvcreate l 100%FREE vg1 n lvs (This cmd says that 100% of free space of volume group 1 and give it the name lv1) #lvs (Shows the created volume information)

CREATING EXT4 FILE SYSTEM ON THE NEWLY CREATED LOGICAL VOLUME: #mkfs.ext4 /dev/vg1/lv1 #mkdir /anyname #vim /etc/fstab #/dev/vg1/lv1 /anyname ext4 defaults 0 0

#wq or x to save the written.

#mount a #mount #df h /anyname

(This cmd will mount everything mentioned in the fstab file) (This cmd is used for viewing the mounted partition) (Show the newly created volume)

EXTENDING A VOLUME GROUP FROM THE LVM FREE SPACE: #vgextend vg1 /dev/sdb7 #vgs (adding the sdb7 free space to the vg1) (This cmd will show you the volume details)

EXTENDING THE LOGICAL VOLUME: #Lvextend /dev/vg1/lv1 l 100%VG (This cmd will give you the 100% space from the free space. Logical volume will successfully resized) #df h (you will see the previous partition info, not the added one, recently)

UPDATING THE FILE SYSTEM: #resize2fs /dev/vg1/lv1 #df h /anyone (The modification is successfully done) (Now you can view the extended LVM space)

POST-INSTALLATION, VALIDATION, AND CONFIGURATION LOOKING INTO THE INSTALLATION LOG (WHAT SOFTWARE IS INSTALLED IN YOUR SYSTEM: #su #more /root/install.log or more /tmp/install.log #cd /var/log or more /var/log/dmeg or dmeg | less (The above cmd shows the system startup messages. The dmesg tells you what actually happens at the boot time. If you get trouble with a particular device which you want to get working under linux then check the output of the dmeg cmd).

#system-config-services (This cmd shows you the services that starts automatically when your system starts.)

ADMINISTRATION OF GROUPS, QUOTAS AND SUDO PRIVILEGES #groupadd groupname1 #groupadd groupname2 #cat /etc/group (1st group creation) (2nd group creation) (You can view the groups that you created recently) #usermod G groupname1 username1 (This cmd will set the existing user in the mentioned groupname1) #cat /etc/group (You can view the username1 under the groupname1) #usermod G groupname2 username1 (This cmd will change the group owner to the mentioned groupname2 forcefully from the existing groupname1) #cat /etc/group #usermod G group1,group2 username1 (You can view the changes) (This cmd will make username1 in multiple groups) #mkdir projectX #chgrp groupname1 dirname(ProjectX) (Make dir in /home directory) (Sharing a directory within the same group. The Groupname1will own the directory ProjectX. Anybody within the ProjectX group can access the mentioned directory.)

#info groupdel

QUOTA MANAGEMENT #rpm qa #rpm qa | grep quota #rpm ql quota (Shows the quota package)

QUOTA MANAGEMENT: #vi /etc/fstab #mount o remount /home (Change mount options in fstab: /home defaults,usrquota) (Activate changes by remounting, if youre mounting the / dir then you just have to restart the machine you cannot mount it when the system is on) #mount (Here you can view whether you have enabled the usrquota & grpquota or not, as it reflects after the /home info) # quotacheck mcug /home (m=override, c= create new quota files) - quotacheck aguv - quotacheck avcm #ls /home #edquota username #edquota t or (Here you can see the aquota.user (Edit quota soft=1024(1MB), hard=2048(2MB), 5000000=5GB) (Default grace period is 7 days, so you can use the soft limit only for 7 days if the period is over then you cannot be able to reach the hard limit) -edquota T username #less /etc/warnquota.conf (change to 60seconds) (It examines the configuration file and send warning msgs to the users (All partitions, grp & usrquota, verbose)

of the system. It makes an email msg to the user who exceeded their quota using the sendmail command from the root user (root@localhost). This is the configuration file for creating the email msg when a user exceed their disk space) #repquota s / | less (This just generates the report and the disk usage of the various user on the system and how that compares to their quotas, -s is for readable format data output).

#quotacheck cM /home #quotaon /home

(Create aquota.user & aquota.group, or: (Prepare quota for restart at boot (/etc/init.d/quotad start, make sure quota management is started) (chkconfig a quotad, Prepare for runlevel 2,3,5 after reboot)

#edquota u username

(Edit usrquota (-u) g is grpquota.) soft (36), hard (40), inodes (349)

# edquota t #repquota /home #quotaon p /home

(To modify grace period) (To view the configuration) (To confirm current quota status whether its on or not)

CHECK AND TEST THE QUOTA STATUS AND LIMITS (1Block = 1KB): #quota #repquota aguv #dd if=/dev/zero of=bigfile bs=1M count=5 #du a /home | sort nrb | less

You might also like