Unix The Basics Unix For Mac

How to Use Basic UNIX Commands to Work in Terminal on Your Mac If you’re on your Mac, you need to know the most important UNIX commands: those that work with directories, those that work with files, and miscellaneous but commonly used commands. 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 Command What It Does ls Lists the names of the files in the working directory. For more complete information, use ls –alF (. Cd directoryname Changes the working directory to the one you named. Brings you up one directory level. Cd Returns you to your home directory.

Unix The Basics Unix For Mac

Unix The Basic Unix For Mac

Pwd Displays the pathname of the current directory. Mkdir newdirectoryname Makes a new directory. Rmdir directoryname Removes (deletes) an empty directory. As in Windows, you can redirect the output of a command to a text file. 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.

Unix

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.

An A-Z Index of the Apple macOS command line. Or rename files or directories n nano Simple text editor nc/netcat Read and write data across. A file created by uuencode uuidgen Generate a Unique ID (UUID/GUID) uucp Unix to Unix copy. Here, when I use the term Unix, I refer to all Unix-like computing environments, i. The original Unix that comes with Macs as well as most Linux flavours. This tutorial was originally designed to be run on the computer cluster of the University of Sheffield called Iceberg.

Working with Files Command What It Does cp filename1 filename2 Copies a file. Chmod Changes permissions for access to a file.

Study the man page before using this one. Diff Compares two files line by line (assumes text). More filename Displays a text file one page at a time. Press the spacebar to see the next page; press Q to quit. The man command works through more. Mv filename1 filename2 Moves a file or changes its name.

Rm filename Removes (deletes) a file. This last table explains other handy commands that anyone getting started in Terminal will likely want to know. Miscellaneous Commands Command What It Does Control+C Terminates most operations. Date Displays the current date and time. Echo Repeats whatever appears after the command (after expansion). Help Displays a partial list of bash commands. History Displays the last commands you typed.

You can redo a command by typing an exclamation point (!) followed immediately (no space) by the number of that command in the history list. To repeat the last command, type!! To repeat the last filename, type!.

Pico A simple UNIX text editor. Ps Displays a list of running processes. Sudo Lets you carry out commands for which the account you are using lacks authority. You will be asked for an administrator’s password. 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.

Posted :