basic unix commands
The following examples will use the aoce and highered directories as examples. To clarify the directory structure is as follows: /www/wwwroot/aoce/highered. As you can see highered is a subdirectory of aoce. When in a Unix shell, to get more detailed information including options, syntax and examples type "# man command name” to bring up the manual page for the command in question. Example: "# man cp" would give you the manual page for cp (copy). Use the arrow keys on your keyboard to navigate up and down. When finished with a man page type “q” to exit back to your terminal.
navagating the filesystem
cd - change directory, Example: "# cd aoce/highered" to move from the root of www to aoce/highered.
ls - list contents of current directory, Example: if you were in the highered directory typing ls would show the files inside that directory. Try "#ls –al" for more detailed listing.
dir – similar to ls, for the benefit of windows users.
pwd – print working directory, Example: if unsure of what directory you are in "# pwd" to give you the path to your current directory
moving files around
cp – copy, Syntax cp origin destination. Example: "# cp /www/wwwroot/aoce/highered/file /www/wwwroot/aoce/" this would copy the file “file” from highered to aoce. It is also ok to use relative paths, just like you would for links in a web page. If you were in the highered directory the above example using relative links would look like this: "# cp file ../". As you can see relative paths can be much easier to type.
mv – move, same syntax as copy but this will move the file from one location to another. Example: "# mv /www/wwwroot/aoce/file /www/wwwroot/aoce/highered/" would move the file “file” from aoce to highered. Relative paths also apply here.
Special note on cp and mv. To change the name of a file you need to use the mv command. Example: "# mv file file2" would rename “file” to “file2”. To perform a save as use the copy command. Example: "# cp file file2" would make a new copy of “file” named “file2”.
creating files and directories
mkdir - make directory, Syntax "# mkdir new_directory_name_goes_here". Example: "# mkdir /www/wwwroot/test" would make the directory test inside /www/wwwroot providing that /www/wwwroot already existed
touch - creates a blank file or updates the files modification and access times. Syntax "#touch new_file_name_goes_here". Example: "# touch /www/wwwroot/test/newfile" would make a blank file called newfile inside /www/wwwroot/test providing that /www/wwwroot/test already existed
changing ownership, groups and permissions.
Note: chown and chgrp can be done from any user account that has the appropriate rights. If you want to change permissions on a file, you must have athority to do so. Very often I use these commands logged in as "root".
chown – change owner, syntax: "# chown newownername filename"
chmod – change attributes, syntax: chmod options filename. This is a tuff one to learn, the options section is for “rwx” as in read write and execute. Typically files that are static html for public access on a webserver would be read, write and execute for the owner and group but only read and execute for everyone else. In the event that a file has been created by a user that accidentally had the group permissions not at least set to “rw” other webmasters would not be able to change the file. I prefer using the numeric values for changing attributes of a file. It’s really pretty easy but you have to practice to figure it out. Here is the formula. Read=4, Write=2, Execute=1, add the values to come up with the appropriate permissions. Example If you wanted to change a file so that owner and group could do anything to the file, but others (everyone else) could only read and execute the file, type "# chmod 775 file_or_directory_name_goes_here". The "775" is giving (owner rwx, group rwx, and other rx). This allows the owner and group full privileges, but, does not allow others to change the file.
chgrp – change group, syntax: "# chgrp group_name file_or_directory_name_goes_here".
special note about chown and chgrp - Read the man pages for these commands for options that can be used. I very often use the recursive option on directories that contain subfolders and such. All of these commands are fully documented in the man pages, if you need more info see instructions on how to pull up a man page at beginning of this section.