![]() |
![]() |
|
|
|||||
|
|
UNIX Commands GETTING STARTED If you plan to work with cgi scripts or password protection, you'll need to make sure you have the right tools and that your account is set up properly:
You should now be ready to get started. Using your SSH application, log into your account by entering the hostname, username, and password. You'll be presented with the system prompt, which looks like this: tarantula % This is where you'll type your UNIX commands. Many of the basic commands are listed below. For more detailed information on these and other commands, you can also refer to the UNIX man pages by typing man command at the system prompt. For example, to learn more about the ls command, type man ls at the tarantula% prompt as shown here: tarantula % man ls UNIX COMMANDS ls — Get a listing of your files ls lists the names of the files and subdirectories located in the current directory. The list will look something like this: picture.gif index.html more_stuff ls -al — Get a detailed listing of your files This command lists the files and subdirectories along with additional information. In the example below, notice the "d" in the first position of the third row. The "d" stands for directory, so you now know that this directory contains 3 files and 1 subdirectory. (NOTE: Some info has been deleted for space reasons; deleted info has been replaced with . . . .) -rw-rw-r-- 1 news_www . . . picture.gif pwd — Determine what directory you're in (i.e., the current directory) cd newdirectory — Change from the current directory to another directory This command moves you to a different directory. For example, to change from directory /www/html/unlv/mydir to the subdirectory stuff, type: cd stuff This will place you in /www/html/unlv/mydir/stuff. cd .. — Move up one directory level If you are currently in /www/html/unlv/mydir/stuff, for example, type: cd .. This moves you to /www/html/unlv/mydir. mkdir directoryname — Create a new directory To create a directory called images, for example, type: mkdir images rmdir directoryname — Remove a directory The directory must be empty. If not, remove any remaining files, then run the command again. chmod xxx directoryname — Change access permissions on a directory The chmod (change mode) command lets you change the access permissions of a file or directory. You determine what privileges you wish to grant by setting a numeric figure. The first digit pertains to the owner's privileges (that's you), the second pertains to the group's privileges (users who are members of the same group), and the third pertains to the world's privileges (i.e., the people viewing your webpages). Each digit is determined by the addition of three components: read = 4 Suppose I have a directory that I don't want anyone but myself to be able to access. By default, the web server sets file permissions to 755 (read/write/execute for the owner and read/execute for the group and world). To make the directory accessible to only myself, I would issue the following command: chmod 700 directoryname This gives me full privileges as the owner (4+2+1) and no privileges to anyone else (0). TIP: Set the execute bit when you have a directory or an executable file (cgi script). Also, never give write permission to the world unless you don't mind other people tampering with your files. For more details, refer to the man pages. clear — Clear the screen Clears the screen and moves the tarantula % prompt to the top of the screen. exit — Logout Logs you out when you're through with your session. cp file1.html file2.html — Copy a file For example, to copy the file events.html to schedule.html, type: cp events.html schedule.html rm filename.html — Remove (delete) a file Use this command carefully. Once deleted, your file is gone forever! chmod xxx filename.html — Change access permissions on a file The chmod (change mode) command lets you change the access permissions of a file or directory. You determine what privileges you wish to grant by setting a numeric figure. The first digit pertains to the owner's privileges (that's you), the second pertains to the group's privileges (users who are members of the same group), and the third pertains to the world's privileges (i.e., the people viewing your webpages). Each digit is determined by the addition of three components: read=4 Suppose I have a cgi script that I need to make executable. By default, the web server sets file permissions to 644 (read/write for the owner and read only for the group and the world). That means that the server won't execute my script until I change the permissions. I want to have read, write, and execute privileges for myself (4+2+1) as the owner, but want to limit everyone else to read and execute (4+1). IMPORTANT: Never give write permission to the world or you'll be putting your files at risk. Here's the command I would issue to make the file executable: chmod 755 myscript.pl For more details, refer to the man pages. mv oldfile.html newfile.html — Rename a file Use this command to rename a file or to move a file to another directory. |
|
||
![]() |
|||||