Lecture 2a - Common Unix Commands and Their Usage
Structure of a Unix Command
Unix Commands all have a similar structure:
COMMAND FLAGS PARAMETER(S)
Flags: Flags are options available on commands. Not all
commands need flags. Some REQUIRE them.
Note that spaces need to seperate the command from the
flags, and the flags from the parameters, and the
parameters from other parameters.
You can combine multiple flags under one - or have each
flag listed with it's own -
Useful Unix Commands
What do they do? How and why do we use these
commands?
Below is a small list of commands we
will go over in class. SOME of the flags useful with them
are listed as well.
- ls : list contents of a directory
- usage:
ls directoryPathname
--
lists
items in specified directory. - Flags: -l -a
(there's more too!)
- cat : view file contents
- usage:
cat filenameToView
- more : view file contents, but pause each
screen. Page through each screen with space bar.
- usage:
more filenameToView
- less : view file contents, pause each screen,
space bar, use of arrow keys.
- usage:
less filenameToView
- touch : creates file or updates file timestamp
- usage:
touch SomeFilename
- cp : copy file to another file or location
- usage:
cp WhatToCopy
WhereToCopyTo
- Flags: -i -r
- mv : move file to another file or location (move file
to another file, whaaaaaa?)
- usage:
mv WhatToMove WhereToMoveTo
- rm : remove file (or directory... hm...)
- Flags: -r Recursively Removes. Use this when removing a directory and everything in that directory.
- pwd : displays absolute pathname to current
directory
- mkdir : create directory
- usage:
mkdir
NewDirectoryName
- rmdir : remove directory (EMPTY ONES ONLY!)
- usage:
rmdir
DirectoryToRemove
- cd : (change directory) navigate
through directories
- wc : word count
- usage:
wc
FileToTakeWordCountOf
- flags: -w -c
-l
- passwd : use this command to change your account
password
- man : use the man command with any other command name
as a parameter to open up a manual page to see useage
notes and flags available with any unix command. (you can
also list any command name with --help afterwards to see
a smaller help page).
Back to Course Homepage
(c) Melina Vastola, 2015