Qindex Programming Tips
107 [Quick Reference] Linux, Apache
written by Qindex at 2008-01-26 11:08 /



- user -


add user

[shell]$ su -
Password: ****
[root]# /usr/sbin/useradd yitaiyub


list user

[root]# cat /etc/passwd


change password


[user]$ passwd

Changing password for user roger.
Changing password for roger
(current) UNIX password: ****
New UNIX password: ****
Retype new UNIX password: ****

passwd: all authentication tokens updated successfully.


[root]# passwd roger
Changing password for user roger.
New UNIX password: ****
Retype new UNIX password: ****
passwd: all authentication tokens updated successfully.


delete user

[root]# /usr/sbin/userdel -r yitaiyub




change mode

[shell]# chmod 755 /home/Qindex/index.html

change all contents of yabbfiles to 755

[shell]# chmod 755 -R yabbfiles


change the owner of a file

[shell]# chown Qindex Kallery.tar.gz


compress a directory

[shell]# tar -zcvf Kallery.tar.gz /home/Kallery

copy a file

[shell]# cp phpspy2011.php phpspy2011.php_


current working directory

[shell]# pwd


create a symbolic link

[root] ln -s /var/named/chroot/var/named/qindex.info.zone ./qindex.info.zone

create a directory

[shell] mkdir www

extracting (tar)

[shell]$ tar -xzvf YaBB_2.2.2.tar.gz  

find a file

find /home -name 'index.html'


find a string from a file

grep "Qindex" /home/Qindex.html


list files

(list in modification time, revere order, The old one appears first.)

[shell]# ls -ltr

(list in size order, The small one appears first.)

[shell]# ls -l|sort


[shell]# /etc/init.d/sendmail restart

move a file

[shell]# mv Qindex.sql /home/Qindex/Q_strg



[shell]# mysqldump -h localhost -p Qindex -u Qindex -r Qindex.sql


remove a directory

[shell]$ rm -rf directory_name
rm: remove write-protected regular file `directory_name/manual/2753032742452270336264272276363_html.zip'? y


reset time & timezone

become a superuser

[...]$ su

show current time
[...]# date
Mon May  5 09:04:10 EDT 2008

reset time
[...]# date -s  "Mon May  5 09:32:10 JST 2008"
Sun May  4 20:32:10 EDT 2008

show universal time
[...]# date -u
Mon May  5 00:39:40 UTC 2008

create a symbolic link from the appropiate timezone to /etc/localtime
[...]# ln -sf /usr/share/zoneinfo/Japan /etc/localtime
update the current system time
[...]# /usr/bin/rdate -s time.nist.gov

set the ZONE entry
[...]# vi /etc/sysconfig/clock

set the hardware clock
[...]# /sbin/hwclock --systohc


switch user - becoming superuser

[user]$ su


[root]# exit



[shell]$ uname -a 



view file contents

[user]$ less file_name


vi editor

vi /path/to/file

Press i to enter the Insert mode. To leave the Insert mode press ESC.

To delete the character that is currently under the cursor you must press x

If you have made changes and want to save the file, press :x

If you haven't made any changes, press :q to leave the file

If you have made changes, but want to leave the file without saving the changes, press :q!

You can use your keyboard's arrow keys to navigate the cursor through the text.


[permission] read:Anonymous, comment:Anonymous, write:Webmaster, upload:Webmaster, manage:Webmaster