________ SWAT MAGAZINE ISSUE TWENTY-FOUR DECEMBER 1999 ________ / \______________________________________________/ \ / Guide to the UNIX command line - part 2 \ / By qwaszx \ ----------------------------------------------------------------------- Last month I started this tutorial, describing some of the commands you can use in UNIX, and introducing the concept of files along with copying, moving and deleting. This article will continue with the idea of file permissions... If you log in to your UNIX account and type in the following command: ls -l then you should get a directory listing of your home directory, which should look something like drwx------ 3 qwaszx users 1024 Nov 17 12:23 bin -rw------- 1 qwaszx users 747 Nov 9 17:23 dead.letter drwx------ 2 qwaszx users 1024 Nov 17 13:50 incoming drwx------ 2 qwaszx users 1024 Nov 14 01:52 mail -rw------- 1 qwaszx users 1558 Nov 20 19:52 mbox drwx--x--x 5 qwaszx users 1024 Aug 27 12:59 public_html Now the important thing in this case is all that gobbledegook on the left. That is showing the permissions of all your files, ie. who can access them. First off - an explanation of how permissions work... There are three types of user that you can set permissions for. These are: User - that's you Group - that's everyone who is in your 'group'. This could just be you, or it could be everyone on the server. it just depends on how your administrator has set things up. Other - Everyone else basically And there are three different actions that you can prevent or allow a user to do to that file: Read - User can read the content of the file Write - User can change and delete the file Execute - User can run the file as a program. For directories, the execute flag allows you to set that directory as your current directory. The column on the left shows what permissions are set for each group of users. ie. -rwxrwxrwx 2 qwaszx users 1024 Nov 14 01:52 mail \_/\_/\_/ | | | | | | | Owner Group Filesize Filename | | Other | Group User To change these permissions, you use the chmod command. The format is as follows: chmod (a|ugo)(+|-)rwx filename or chmod 777 filename the numbers is just another way of writing the permission information. For now, we will use the first form of the command as it is easier to use. Say for example you wanted to give everyone read access to your file, you would use the following command: chmod a+r filename The a means all users, the plus means turn ON the required permission, and the r means set the read permissions. These letter can be put together in any combination eg. chmod go-rwx private_file would remove all permissions for anyone except yourself. The uses of permissions are obvious, and it is a good idea to do the following commands on your shell account: chmod go-rwx ~/* # Protects all files in your home directory chmod go-rw ~ # Protects your home directory itself chmod go+rx ~/public_html # Allows read access to your website In the next article I will cover networking commands in UNIX (Telnet, commmand line FTP, etc.) --- Written by qwaszx for SWAT Magazine Send comments, suggestions, praise to Send Flames to Standard disclaimer applies - I am not reponsible for what you do with this information, and for any inaccuracies. blah.. blah.. blah......