cd cd (change directory) is the command you use to change into a different directory. Example: You would type cd /var/www/html to access the html directory (which is inside of the www directory, which is inside of the var directory). To move up one directory you would type cd .. (there is a space between cd and the ..) ~ represents your home folder AND will take you directly to your home folder by typing cd ~ at the prompt. For example, typing the following two paths at the command prompt will give you same result! /home/trevor_gontz/public_html ~/public_html to access access a directory that contains spaces and/or special characters and punctuation in its name, put the name in quotes: Example: To access New Folder you would type: cd "New Folder" ls ls (list) is the command used to show/list all of the files in the current directory. You can also list the files of another directory by typing ls and then the full path to that directory. Specific example: Typing ls /etc/httpd/conf will list the files in the conf directory (which is inside of hte httpd directory which is inside of the etc directory). In addition, typing -l after ls will show/list the files in a directory along with the permissioins of each file and/or folder! ls -l displays permissions of files and directories within a folder cp The cp (copy) command has two functions. It is used to simply copy a file to another location and it is used to both copy and rename files simulatenously. Because of its dual purpose, the cp command can be used in several ways. To copy a file from from the current directory to another directory you would type: cp file_name other_directory. Specific Example: If you are in the /etc/httpd/conf directory and you want to make a backup copy of your httpd.conf file to your home directory you would type: cp httpd.conf /home/yourusername To copy a file from a directory without being in that directory ould do the same thing only you would have to specify the location of the file being copied. For example, if you were not in the /etc/httpd/conf folder and wanted to do the same thing as above you would type: cp /etc/httpd/conf/httpd.conf /home/yourusername To rename a file within the current directory you simply type: cp current_name new_name Specific example: If you are in the the /etc/httpd/conf directory and you want to make a backup of original httpd.conf file before editing it you would type: cp httpd.conf http.conf.orginal If you are not in the /etc/httpd/conf folder you would have to type the full path to the file. For example: cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.original To copy a file to a new folder and rename it at the same time you would type: cp /path/file_name /newpath/new_name Specific example: cp httpd.conf /home/yourusername/httpd.conf.original will make a copy of the httpd.conf file (assuming you are currently in the /etc/httpd/conf directory this would make a backup of the httpd.conf file under the name httpd.conf.original in your home folder) mv mv (move) is similar to cp except that mv moves a file rather than copying it. Therefore, mv can be used to move, rename, and move and rename files simultaneously. mkdir mkdir (make directory) is the command to create a new directory. to creat a directory with spaces in the name, put the name in quotes: For example, mkdir "New Folder" will create and new directory titled New Folder rm rm (remove) is used to delete files and directories with files in them. Normally, when using rm you will be prompted to confirm removal of the file, to eliminate this confirmation step add the -rf option to the rm command. Also, you cannot delete directories that are not empty unless you use the -rf option. Use the -rf option very carefully! rmdir rmdir (remove directory) is used to delete empty directories. man man (manual) displays the man page (manual) for an application or command. For example: Typing man rm at the command prompt will open the manual for the rm command. locate locate is the command you use to find files. You simply type locate and then the name of your file! Specific example: To find your httpd.conf file you would type locate httpd.conf. *Note: In order to use locate you must first run the updatedb command.
|