Open main menu

CDOT Wiki β

Changes

ULI101 Week 2

270 bytes removed, 12:03, 31 August 2017
Basic Commands
= Basic Commands =
<dl><dt>; <code>pwd</code></dt><dd><p>: Displays the user's present working directory to show where the user is located on the computer system in order to build directories, copy files, etc</p></dd><dt>; <code>cd path/to/dir</code></dt><dd><p>: Changes pwd to <code>/path/to/dir</code>. Entering the cd command without the directory path will change to the userfs home directory.</p></dd><dt>; <code>ls</code></dt><dd><p>: Displays the contents of a directory (eg. regular files or sub-directories). By default, the ls command displays non-hidden filenames only. The following are common options associated with the ls command: <code>-a</code> short display of hidden &amp; non-hidden files <code>-l</code> detailed display of files excluding hidden files <code>-F</code> displays / after directory, * after executable file Options can be combined, for example: <code>ls -la</code> (or <code>ls -l -a</code>)</p></dd><dt>; <code>mkdir path/to/dir</code></dt><dd><p>: Creates a subdirectory with a directory. Multiple arguments can be used to create many subdirectories. The option .p allows for parent directories to be created.</p></dd><dt>; <code>rmdir path/to/dir</code></dt><dd><p>: Removes only empty directories (i.e. directories that contain no subdirectories or regular files). A user cannot remove a directory from within the directory location itself.</p></dd><dt>; <code>mv path/to/source path/to/destination</code></dt><dd><p>: Moves a file from one location to another and/or rename the file. The mv command can be used to move directories as well as files. The <code>-i</code> option asks for confirmation if the destination filename already exists.</p></dd><dt>; <code>cp path/to/source path/to/destination</code></dt><dd><p>: Copies a file from one location to another. The cp command can be used to backup important files. The <code>-i</code> option asks for confirmation if the destination filename already exists. The <code>-r</code> option allows copying of directories and their contents</p></dd><dt>; <code>rm path/to/file</code></dt><dd><p>: Removes a regular file. The <code>-r</code> option is used to recursively remove a directory and it's contents. Recursive means to descend to lower levels, which in this case, indicates that subdirectories and it contents are also removed. Note: it is a good idea to include the .i option to confirm deletion of subdirectories and its contents!</p></dd><dt>; <code>cat path/to/file</code></dt><dd><p>: To join files (i.e. to concatenate files). For example, <code>cat file1 file2 file3</code> will display the contents of file1 and file2 and file3 on the screen at the same time. To display the contents of small files (files longer than the screen will scroll to the end). For example, issuing the command <code>cat .bash_profile</code> in your home directory would display the contents of your setup file.</p></dd><dt>; <code>more path/to/file</code></dt><dd><p>: Displays the contents of large regular files one screen at a time. The user can navigate throughout the file by pressing keys such as:</p> 
{|
| spacebar
| Exit to shell
|}
</dd><dt>; <code>less path/to/file</code></dt><dd><p>: Works like more command.</p></dd><dt>; <code>touch path/to/file</code></dt><dd><p>: Updates the date and time of existing files. The touch command is also used to create empty files. You will be using the touch command to create empty files when you practice the file management on-line tutorial</p></dd>. <dt>; <code>file path/to/file</code></dt><dd><p>: Determines a file type Useful when a particular file has no file extension or the extension is unknown/incorrect</p></dd></dl>
= The find Command =
221
edits