Basic Linux Commands
One does not need to know very many commands in order to get around on a connection to a remote machine pretty easily. Here we give a simple list of some of the most commonly used commands for Linux/Unix. Note that most commands can accept options that change their behavior. For example, ls provides a listing of the contents of the current directory, while ls -l gives that listing in long format, including many more details about each file in the directory. On the other hand, ls -a lists all the files in the directory, including the "hidden" ones. We can mix options simply by chaining them together; e.g. ls -la gives a listing of all files in a long format.
Remember that you can get a full description of the usage of any command by typing man commandname in a terminal.
Command | Function | Example Formats |
---|---|---|
cd | Change Directory |
cd cd directory/path |
chmod | Change Mode - file permissions |
chmod u+w file_name chmod 755 file_name |
cp | Copy files | cp from_file to_file |
exit | Exit the shell | exit |
less | List contents of a file | less file_name |
ls | List filenames in a directory | ls ls -l ls file_name |
man | Manual pages |
man cp man mv |
mkdir | Make a Directory | mkdir directory_name |
mv | Move a file | mv from_file to_file |
nano | Start a primitive editor | nano file_name |
pwd | Print Working Directory | pwd |
rm | Remove a file | rm file_name |
rmdir | Remove a Directory | rmdir directory_name |
There are a few "wildcard" characters that can match many things. The question mark matches any single character. Thus, ls image?.jpg would list all of the files image1.jpg, image9.jpg, and imageA.jpg on a directory, but would not list image23.jpg The asterisk matches any number of characters, so that ls image*.jpg would list image1.jpg, image23.jpg and image49027.jpg.
The last test will take place at the final exam time on
Tuesday, 12 December, from 1:30-3:30. It will be written as a one-hour (not
50 minute) exam, but you may have the full two hours for it.
In other respects it will be very like the other tests, but
comprehensive - it will emphasize Python, but cover all the
topics we have seen.
There is a
Sample Exam, but be aware that things will have changed somewhat
with the advent of ChatGPT.
The scores are posted on the Info tab at
My.math.
Notify the instructor of discrepancies immediately.