改变文件或目录之读、写、执行之允许权 执行格式:chmod [-R] mode name ( name 可为文件名或目录名;mode可为 3 个 8 位元之数字,或利用ls -l 命令,列出文件或目录之读、写、执行允许权之文字缩写。) mode : rwx rwx rwx r:read w:write x:execute(user group other 缩写为: u g o) Example : % chmod 755 dir1 将目录dir1,设定成任何使用者,皆有读取及执行之权利,但只有拥有者可做修改。 % chmod 700 file1 将文件file1,设定只有拥有者可以读、写和执行。 % chmod o+x file2 将文件file2,增加拥有者可以执行之权利。 % chmod g+x file3 将文件file3,增加群组使用者可执行之权利。 % chmod o-r file4 将文件file4,除去其它使用者可读取之权利。
改变文件或目录之拥有权 ====================== 执行格式:chown [-R] username name ( name 可为文件名或目录名。) Example : % chown user file1 将文件 file1 之拥有权,改为使用者 user 所有。 % chown -R user dir1 将目录 dir1,及其下所有文件和子目录之拥有权,改为使用者 user 所有。
检查自己所属之群组名称 ====================== 执行格式:groups Example : % groups
改变文件或目录之群组拥有权 ========================== 执行格式:chgrp [-R] groupname name ( name 可为文件名或目录名 ) Example : % chgrp vlsi file1 将文件 file1 之群组拥有权,改为 vlsi 群组。 % chgrp -R image dir1 将目录dir1,及其下所有文件和子目录,改为 image 群组。
改变文件或目录之最后修改时间(变为当前时间) ========================================= 执行格式:touch name ( name 可为文件或目录名称。) Example : % touch file1 % touch dir1
文件之连结 ========== 同一文件,可拥有一个以上之名称,可将文件做数个连结。 执行格式:ln oldname newname ( Hard link ) Example : % ln file1 file2 将名称 file2,连结至文件 file1。 执行格式:ln -s oldname newname ( Symblick link ) Example : % ln -s file3 file4 将名称 file4,连结至文件file3。
如何设置login后欢迎信息 ==================================== 修改/etc/motd,往里面写入文本,就能使用户通过telnet正确登录后执行shell之前得到相应的提示信息。 motd就是“messages of the day”,也就是当日信息的意思。管理员可以往里面写一些需要注意的事项或者通知等来提醒正式用户。
如何修改网卡MAC地址 ==================================== 首先必须关闭网卡设备,否则会报告系统忙,无法更改。 命令是: /sbin/ifconfig eth0 down 修改 MAC 地址,这一步较 Windows 中的修改要简单。 命令是:/sbin/ifconfig eth0 hw ether 00:AA:BB:CC:DD:EE 重新启用网卡 /sbin/ifconfig eht0 up 网卡的 MAC 地址更改就完成了
如何不显示其他用户的消息 ==================================== 用户可以使用mesg n来禁止别人给他发送信息,其实就是禁止别人往自己的终端上面的写权限。当别人试图再使用write给他发送信息时,发送者将会看见提示: write: user has messages disabled on pts/n
Mounting ISO images (no CD-R required) by Adrian Chung ====================================== You've just downloaded a 650MB ISO file, ready for burning to a CD-R. The MD5 hash checks out, but you're still not sure if the image contains what you want. If you're too impatient to wait for the CD-R to burn, you can browse the actual downloaded file via the loopback device. First create a mount point bash# mkdir /mnt/iso Then mount the .iso file: bash# mount -t iso9660 -o loop Mandrake80-inst.iso /mnt/iso Now browse the directory tree mounted on /mnt/iso. This is useful as a space saving measure when you want access to both the directory tree and to the raw .iso image on the same machine.
Removing ^M from file by Ismail YENIGUL , homepage: http://www.enderunix.org ====================================================== if you have transferred a file from MS Windows to UNIX, you might find that the file looks like this: bleh bleh ^M leh leh ^M tey tey tey^M This is because Windows uses carridge return and newline to indicate a new line. Here are a number of ways to get rid of the ^M characters: 1- cat filename1 | tr -d "^V^M" > newfile 2- sed -e "s/^V^M//" filename > outputfilename where ^V is actually control-V and ^M is actually control-M (you must type these yourself, don't just copy and paste this command from this web page) 3-vi solution : open file with vi 1. hit the ESC key 2. :%s/^V^M// 3 - some distributions contain a command called dos2unix which removes these carridge return characters 4- use the texteditor vim (www.vim.org) and edit the file. If all the lines (not only some) contain consistently the carridge return characters then vim will show [textmode] and when you change the mode with the command :set notextmode it will remove them.
Create /dev/null by Mariusz Zinowicz ==================================== I have moved a file to /dev/null and now my system doesn't work If you move a file with the mv command to "/dev/null" then it will be overwritten with an ordinary file. How to fix it: Boot your system. If it doesn't boot take a one disk distribution like Toms rtbt and mount your /dev/hdXX partition. Now type in a shell "mknod /dev/null c 1 3" to create a nod file. /dev/null is the path where the nod file will be saved. The c stands for a character device and the two numbers are the major and the minor numbers for the null device. After that you must change with "chmod 666 /dev/null" the read, write and execute permissions. With "ls -alF /dev/" you will see all nod files with it's own three parameters like "crw-rw-rw- 1 root root 1, 3 Oct 4 11:34 null ". You will see a "c" in the near of the rwx flags an a " 1, 3" left of the date.
Resetting your terminal/shell window by Buffer_7 ==================================== When accidentally doing a : cat /bin/somefile_binary you can end up with a "broken terminal". The binary file may possibly contain characters that put a terminal into a mode where the output becomes unreadable. To put the terminal back to normal you can type blindly: reset and it's normal. best regards
Howto log in to your server passwordless via ssh ( rsa version ) by Murat Ilker Balaban , homepage: http://www.enderunix.org/ ==================================== Create your private and public keys via ssh-keygen program $ ssh-keygen Computing keys Testing the keys.. Key generation complete.. Enter the file in which to save the key (/usr/home/murat/.ssh/identity) Press enter for the default value... Your identification has been saved in /usr/home/murat/.ssh/identity Your public ket is: blah....blah...blah.... Your public key has been saved in /usr/home/murat/.ssh/identity.pub Now that we have created our `public` key, take your public key which is ~/.ssh/identity.pub to your server, in the ~/.ssh/ directory, create a file named authorized_keys and append the content of identity.pub file to your authorized_keys file now, in your machine, type $ ssh -l username your_remote_machine.domain.com Boom, no password, no headache, you're in the other side...;)
Blocking anyone to su to root by Ismail YENIGUL , homepage: http://apache.cslab.itu.edu.tr ==================================== The su (Substitute User) command allows you to become other existing users on the system. For example you can temporarily become "root" and execute commands as the super-user "root". If you don't want anyone to su to root or restrict "su" command to certain users then add the following two lines to the top of your "su" configuration file in the "/etc/pam.d/" directory. 1- Edit the su file (vi /etc/pam.d/su) and add the following two lines to the top of the file: auth sufficient /lib/security/pam_rootok.so debug auth required /lib/security/pam_wheel.so group=wheel After adding the two lines above, the "/etc/pam.d/su" file should look like this: #%PAM-1.0 auth sufficient /lib/security/pam_rootok.so debug auth required /lib/security/pam_wheel.so group=wheel auth required /lib/security/pam_pwdb.so shadow nullok account required /lib/security/pam_pwdb.so password required /lib/security/pam_cracklib.so password required /lib/security/pam_pwdb.so shadow use_authtok nullok session required /lib/security/pam_pwdb.so session optional /lib/security/pam_xauth.so Which means only those who are a member of the "wheel" group can su to root; and to add a user to wheel group use: root# usermod -G10 username Ok, now everybody can not be root using su. When an user that is not in wheel group runs su command ,he/she can not be root even if he/she writes correct root password.
Disable reboot,halt ,shutdown for users by Ismail YENIGUL , homepage: http://apache.cslab.itu.edu.tr ==================================== On Redhat [root@apache /]# rm -f /etc/security/console.apps/halt [root@apache /]# rm -f /etc/security/console.apps/poweroff [root@apache /]# rm -f /etc/security/console.apps/reboot [root@apache /]# rm -f /etc/security/console.apps/shutdown [root@apache /]# rm -f /etc/security/console.apps/xserver (if removed, root will be the only user able to start x).
How to create many subdirectories in one time by Pascal Mulier ==================================== Sometimes, we want to create 2 or 3 (or more) directories at the same time. For example, you are in "rep1" directory ("rep1" doesn't contain any subdirectory) and want to create rep1/rep2/rep3 With "p" option of the mkdir command , it's very easy : mkdir -p rep1/rep2/rep3
How to delete all files from /tmp? ==================================== Simple question? Well, how do you delete files in directories that start with a dot in the name? Rm -r /tmp/.* WILL DELETE THE WHOLE DISK as it selects also the file /tmp/.. Therefore never try this. The solution is to add two question marks before the '*'-wildcard: rm -rf /tmp/.??* /tmp/* You can put this into /etc/rc.d/init.d/syslog into the "stop)" section. This will clean up /tmp at every shutdown and keep your disk tidy. Do not run the above command while running X11 or before you run startx. X11 needs the /tmp/.font-unix which is created by xfont server and X11 it self creates the directory /tmp/.X11-unix which is needed to talk to the X11 windows.