![]() To copy a file named oldfile in the current directory to the new name newfile in the mystuff subdirectory of your home directory, enter: cp -i oldfile ~/mystuff/newfile (period) indicates the current directory as destination, and the -i ensures that if there is another file named meeting1 in the current directory, you will not overwrite it by accident. To copy a file named meeting1 in the directory /home/dvader/notes to your current directory, enter: cp -i /home/dvader/notes/meeting1. ![]() The general syntax for cp is: cp -i oldfile newfile For this reason, it's safest to always add -i after the cp command, to force the system to ask for your approval before it destroys any files. If you already have a file with the new name, cp will overwrite and destroy the duplicate. This command copies a file, preserving the original and creating an identical copy. If you tamper with the directory permissions of your home directory, for example, you could lock yourself out or allow others unrestricted access to your account and its contents.įor more, see Manage file permissions on Unix-like systems. You can view the permission settings of a file using the ls command, described below.īe careful with the chmod command. To allow anyone who has access to the directory in which myfile is stored to read or execute myfile, enter: chmod o+rx myfile To allow yourself to execute a file that you own named myfile, enter: chmod u+x myfile These categories are abbreviated as u for owner (or user), g for group, and o for other. These permissions are broken down for three categories of user: first, the owner of the file second, a group with which both the user and the file may be associated and third, all other users. Every file (including directories, which Unix treats as files) on a Unix system is stored with records indicating who has permission to read, write, or execute the file, abbreviated as r, w, and x. This command changes the permission information associated with a file. To return to your home directory, enter: cd chmod To move to the root directory, enter: cd / To move to the parent directory of the current directory, enter: cd. To switch to a directory named /home/dvader/empire_docs, enter: cd /home/dvader/empire_docs To switch to a subdirectory (of the current directory) named myfiles, enter: cd myfiles By default, your Unix login session begins in your home directory. This command changes your current directory location. Use the less command (described below) or an editor for reading longer text files.įor more, see Combine several text files into a single file in Unix. To view the contents of a file named myfile, enter: cat myfileīecause cat displays text without pausing, its output may quickly scroll off your screen. To append file1 onto the end of file2, enter: cat file1 > file2 You can use it to read brief files or to concatenate files together. This command outputs the contents of a text file. To show a calendar for just the month of June 1970, enter: cat To show a twelve-month calendar for 2008, enter: cal 2008 To show this month's calendar, enter: cal This command will print a calendar for a specified month and/or year.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |