[ Terminal ] Alt +F6 = Terminal switcher [ Users management ] useradd [option] JohnG -d : to assign homedirectory -u : to assign UID -s : to set shell -g : to assign group ID ex) Linux# useradd JohnG -d /home/user/johng Linux# useradd JohnG -u 1000 Linux# useradd JohnG -s /bin/tcsh Linux# useradd JohnG -g user (groups) Verifying Linux# useradd -D ; to show default value 1 / 12
WTServer3:~/Desktop # useradd -D GROUP=100 HOME=/home INACTIVE=-1 EXPIRE= SHELL=/bin/bash SKEL=/etc/skel GROUPS=video,dialout CREATE_MAIL_SPOOL=no To default value change Linux# useradd -D -g user200 ; to change group ID 200 Linux# useradd -D -d /home/user2 ; to change home directory as /home/user2 Linux# useradd -D -f 0 ; to set active status, if set 0, no more active after expired Linux# useradd -D -e 2009/12/20 ; to set experation day Linux# useradd -D -s /bin/tcsh ; to set shell for user. userdel [option] JohnG Linux# userdel -r JohnG; -r will allow delete home directory Passwd 2 / 12
Linux# passwd JohnG Verifying Linux# cat /etc/passwd man:x:13:62:manual pages viewer:/var/cache/man:/bin/bash news:x:9:13:news system:/etc/news:/bin/bash uucp:x:10:14:unix-to-unix CoPy system:/etc/uucp:/bin/bash JohnG:x:101:101:users:/home/user2:/bin/bash ** If you want to inactive user, put " * " in front of user name *JohnG:x:101:101:users:/home/user2:/bin/bash Identify Linux# whoami root Linux# who am i root pts Nov 20 15:54 (:1011.0) (192.168.1.5) 3 / 12
Linux# id uid=101(users) gid=101(users) groups=101(users) SU Linux# su JohnG ; Changes user account to JohnG Linux# su ; Changes to root in current directory Linux# su - ; Changes to root and moves to root directory. [ Group management ] groupadd user100 Linux# groupadd -g 100 user100 Verifying Check /etc/group Chris@Linux# groups 4 / 12
root users bin sys www dialout public video groupdel user100 Groups Chris@Linux# groups root users bin sys www dialout public video newgrp Chris@Linux# newgrp Hello Chris@Linux# groups Hello root users bin sys www dialout public video [ Directory ] pwd 5 / 12
Chris@Linux# pwd ; to see current directory, PWD stands for Present Working Directory) Chris@Linux# cd ; Change directory ex) Chris@Linux# cd /etc/httpd/ ; absolute path Chris@Linux# cd../../etc/httpd ; path from my directory Chris@Linux# cd or # cd ~ ; home directory Chris@Linux# cd.. ; To move one step up directory Chris@Linux# cd / ; To move top directory Chris@Linux# cd /user/chris ; To move Chris's home directory Chris@Linux# cd &HOME ; To move Chris's home directory Chris@Linux# cd ~ ; To move Chris's home directory ls man ls ; to see details ex) Chris@Linux# ls -l ; long(details) information Chris@Linux# ls -a ; to show filename started with ". ", such as hidden file Chris@Linux# ls -F ; to show characteristic of files Chris@Linux# ls -t ; to sort for latest updated files Chris@Linux# ls -al Chris@Linux# ls /bin ; to show file name only under directory /bin cat 6 / 12
Chris@Linux# cat > test ; create a new file as 'test', Ctl+D to exit Chris@Linux# cat file1 file2 file3 > file4 ; Combining file1, file2 and file3 to make file4 Chris@Linux# cat file1 >> file2 ; To attach file1 to file2 cp Chris@Linux# cp -i ; To confirm overwriting target file if file is exist on destination spot Chris@Linux# cp -f ; Force to overwrite Chris@Linux# cp -r ; To copy directory ex) Chris@Linux# cp.bashrc.bashrc.bak Chris@Linux# cp -f.bash. bashrc.bak ; Force to overwrite Chris@Linux# cp -r Hello/ Hello_Backup Chris@Linux# cp file_1 file_2 file_3./test find Chris@Linux# find / -name hello grep 7 / 12
Chris@Linux# grep HELLO *.doc ; To show all the line with HELLO string on files that has extension with doc. rm Chris@Linux# rm -i ; To confirm each file to delete, this option is default Chris@Linux# rm -f ; To delete without confirmation Chris@Linux# rm./hello/* ; To delete multiple files Chris@Linux# rm -r./hello ; To delete directory(test) Chris@Linux# rm -rf./hello ; To delete directory without confirmation mv ; (rename function included) Chris@Linux# mv file /tmp Chris@Linux# mv file_1 file_2 Chris@Linux# mv./test_1./test_2 mkdir Chris@Linux# mkdir./test Chris@Linux# mkdir -p./test_1/group1/users more / head / tail / less 8 / 12
Chris@Linux# more filename Chris@Linux# head filename ; To show front 10 line of the file Chris@Linux# tail filename ; To show tail 10 line of the file Chris@Linux# head - 100 filename ; To show front 100 lines of the file Chris@Linux# tail -100 filename ; To show tail 100 lines of the file Chris@Linux# less filename ; To scroll up and down rmdir Chris@Linux# rmdir./test Chris@Linux# rmdir -r /test Chris@Linux# rmdir -rf /test ; To delete directory without confirmation alias Chris@Linux# alias dir='ls -al' du Chris@Linux# du./chris ; To show number of files under /chris directory df 9 / 12
Chris@Linux# df ; To show disk usage by mount drive [ System ] shutdown CentOS5@Linux# shutdown -r 17:00 ; shut down now and reboot at 17:00. CentOS5@Linux# shutdown -h now ; halt system and shutdown right now. mount CentOS5@Linux# mount -t iso9660 /dev/cdrom -o ro /cdrom [ Version ] Redhat_Linux# uname -a ; To see version of Kernal Redhat_Linux# pppd -h ; To see version of PPP Redhat_Linux# ls -l/lib/libc.so.5 ; To see version of libc Redhat_Linux# ls -l /usr/lib/libg++.so ; To see version of libc++ Redhat_Linux# ld -v ; To see version of binutils Redhat_Linux# ldd -v and ldd -V ; To see version of ldd Redhat_Linux# ls -l /lib/libtermcap.so.* ; To see version of termcap Redhat_Linux# insmod -V ; To see version of modules Redhat_Linux# ps --version ; To see version of procps [ Service ] To start / stop / restart service CentOS_Linux$ cd /sbin 10 / 12
CentOS_Linux$./service https start / stop / restart To check all services CentOS_Linux$ cd /sbin CentOS_Linux$./service --status-all CentOS_Linux$./service --status-all grep httpd CentOS_Linux$./service --status-all less CentOS_Linux$./service httpd status To list of service and open port CentOS_Linux$ cd /sbin CentOS_Linux$ netstat -tulpn [ PHP ] To check current / running verison 11 / 12
CentOS_Linux$ php -v [ Yum ] To check what package installed on the server. CentOS_Linux$ yum list grep php ; in this example to see php related packages. 12 / 12