Chapter 3: Basic Unix Commands Flashcards
What is the Computer Command Prompt?
eos%
These pages contain documentation on the UNIX commands, including how they are executed, associated options, and what the command does
man
Example
man input:
eos% man commandname
If you receive “No manual entry found for commandname,” it means that the command you typed is not recognized on the NCSU system.
To advance in the document, use the UP and DOWN arrow keys, use “Q” to exit the manual
used to determine your location in the file system
PWD (Print Working Directory)
Example:
eos% pwd
used to navigate through the file tree. It changes your location to a location specified by the pathname that you input
cd (Change Directory)
Example
To move from the EosLabs directory to your home directory (~/).
eos% cd~/
To see the contents of a directory or confirm that a file you requested has moved to the location you wanted
ls (list directory)
eos% ls
OR
eos% ls pathname
dash options (can be used in any order):
- l list the contents in long format (all information, size, date, owner, etc.)
- a list ALL files, even “.” (dot) files and hidden files
- al lists ALL files in long format
To create a directory for storing and organizing other files
mkdir (Make Directory)
eos% mkdir directory_path
Example
To create a directory called MyE115 in your home directory:
If you are in your home directory: eos% mkdir MyE115
In the AFS system, you only have editing (write) access to files located in your account space. Therefore, you must ___ any files that you wish to work with into your home directory (or a sub-directory of your home directory) before attempting to edit it.
cp (copy)
eos% cp source_path destination_path
Example
To copy INLAB2 to your home directory, while you are in the lab-2 directory:
eos% cp INLAB2 ~/
the desired file in a specified location. However, the mv command essentially copies the file and simultaneously deletes the original. The mv command is also used to rename files.
mv (move)
eos% mv source_path destination_path
Example
How would you rename the file oldstuff.txt to junk.txt while in your home directory?
eos% mv oldstuff.txt junk.txt
To remove unwanted files and directories from your AFS space, which is limited, you can use the remove (rm) command. Removed files are permanently deleted. The rm command will ask if you are sure that you want to remove the file. Type “y” if you want to remove it, and “n” if you do not.
rm (remove)
eos% rm filename
Dash options:
-r recursively (go into every subdirectory)
-f forced (stops computer from asking your permission for every single file or directory that is removed)
-rf does not ask permission for all files and directories and works recursively. Required for removing directories.
Example:
How would you remove INLAB2.txt from your MyE115 directory, if you are in your home directory?
eos% rm MyE115/INLAB2.txt
rm: remove MyE115/INLAB2.txt (yes/no)? y
creates a log file of every command executed, and its output, during that terminal session
script (create a log file)
eos% script -f logfilename
Script has two associated options. The –f is required for this course. It forces the script to start recording immediately. The other option is –a (append) which allows the user to continue recording on a previously created log file.
To close the log file, type “exit” into the terminal window. For this course, DO NOT exit a log file until instructed.