Folders are called directories in. Commands that refer to filenames, as most do, assume that you’re talking about files in the working directory. When you open the Terminal window, the working directory is set to your home directory, abbreviated. Bash shows you the current working directory and your username to the left of its prompt. The following table lists common directory-related commands. UNIX Directory Commands CommandWhat It DoeslsLists the names of the files in the working directory. For morecomplete information, use ls –alF (.cd directorynameChanges the working directory to the one you named.cd.Brings you up one directory level.cdReturns you to your home directory.pwdDisplays the pathname of the current directory.mkdir newdirectorynameMakes a new directory.rmdir directorynameRemoves (deletes) an empty directory.As in Windows, you can redirect the output of a command to a text file.
![]() ![]()
Terminal provides a command line interface to control the UNIX-based operating system that lurks below macOS (or Mac OS X).
So if you want a record of the files in a folder, type cd, followed by a space, drag the folder’s icon to the Terminal window, and press Return. Type ls mydirectorylist.txt and press Return again. A file named mydirectorylist.txt will appear in the folder you chose. You can open the file in TextEdit to see a list of the files in that directory.This table lists commands commonly used when working with files in the Terminal window. Working with Files CommandWhat It Doescp filename1 filename2Copies a file.chmodChanges permissions for access to a file. Study the man pagebefore using this one.diffCompares two files line by line (assumes text).more filenameDisplays a text file one page at a time. Press the spacebar tosee the next page; press Q to quit.
The man command works throughmore.mv filename1 filename2Moves a file or changes its name.rm filenameRemoves (deletes) a file.This last table explains other handy commands that anyone getting started in Terminal will likely want to know. Miscellaneous Commands CommandWhat It DoesControl+CTerminates most operations.dateDisplays the current date and time.echoRepeats whatever appears after the command (afterexpansion).helpDisplays a partial list of bash commands.historyDisplays the last commands you typed. You can redo a command bytyping an exclamation point (!) followed immediately (no space) bythe number of that command in the history list. To repeat the lastcommand, type!! To repeat the last filename, type!.picoA simple UNIX text editor.psDisplays a list of running processes.sudoLets you carry out commands for which the account you are usinglacks authority.
You will be asked for an administrator’spassword.When you’re working in Terminal, you don’t have a Trash Can to which deleted files are moved pending ultimate disposal. Delete it, and it’s gone. In general, UNIX has no Undo function.
![]() Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
January 2023
Categories |