Please follow and complete the free online Command Line Crash Course tutorial or Codecademy's Learn the Command Line. These are helpful tutorials. Each "chapter" focuses on a command. Type the commands you see in the Do This section, and read the You Learned This section. Move on to the next chapter. You should be able to go through these in a couple of hours.
###Q1. Cheat Sheet of Commands
Make a cheat sheet for yourself: a list of at least ten commands and what they do, focused on things that are new, interesting, or otherwise worth remembering.
- source - activate changes made to .bash_profile in the current session
- pwd - prints working director
- which - prints location of binary referenced by command
- chmod - change file modes (permissions)
- env - return list of environment variables set
- cp - copy files
- mv - move files
- rm - delete files
- sort - alphabetically sort lines in a file
- sed - stream editor sort of like find and replace for in-console text streams
###Q2. List Files in Unix
What do the following commands do:
ls
ls -a
ls -l
ls -lh
ls -lah
ls -t
ls -Glp
ls
- lists files in current directory
ls -a
- above, but all files, including hidden
ls -l
- lists files in long formatting mode, with permissions and other file metadata
ls -lh
- same as ls -l except filesizes have suffix abbreviations
ls -lah
- same as ls -lh, except shows hidden files
ls -t
- sorts by time modified
ls -Glp
- G adds color, p adds trailing slash to directories, l adds long formatting
###Q3. More List Files in Unix
Explore these other ls options and pick 5 of your favorites:
-G
colors, easier to read
-p
clearly identifies directories
-R
displays subdirectories as well
-m
displays names as comma-separated list, might be useful for programming
-d
displays only directories
###Q4. Xargs
What does xargs
do? Give an example of how to use it.
xargs
allows passing arbitrary numbers of arguments to commands. Invoking xargs
will issue a single command for each argument, so one could use it to delete files returned by find
.