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.
Here's a list of items with which you should be familiar:
- show current working directory path
- creating a directory
- deleting a directory
- creating a file using
touch
command - deleting a file
- renaming a file
- listing hidden files
- copying a file from one directory to another
Make a cheat sheet for yourself: a list of at least ten commands and what they do. (Use the 8 items above and add a couple of your own.)
pwd
- show current working directory pathmkdir
- creating a directoryrm -r
- deleting a directorytouch [filename]
- creating a file usingtouch
commandrm [filename]
- deleting a filemv [Path to filename] [Path to new filename]
- renaming a filels -la
- listing hidden filescp [Path to file] [New Path]
- copying a file from one directory to anothergrep [regex] *
- find all instances of a given regex in current directoryenv
- list all environment variablescat [filename]
- display contents of file in current directory to STDOUTless [filename]
- view contents of file by pagesudo su
- switch user to root
What do the following commands do:
ls
ls -a
ls -l
ls -lh
ls -lah
ls -t
ls -Glp
ls
- display contents of current directory
ls -a
- display all (including hidden) contents of current directory
ls -l
- display contents of current directory in long list format
ls -lh
- display file/folder sizes of current directory in human readable format
ls -lah
- display all contents of current directory in human readable long list format
ls -t
- sort contents by last time modified
ls -Glp
- display long list without group names and by appending '/' to directory names
Explore these other ls options and pick 5 of your favorites:
ls -Rl
- display list of subdirectories contents recursivelyls -lX
- list sorted by name alphabeticallyls -lS
- list sorted by file sizels -lah
- long list of all files with human readable sizesls -lt
- list sorted by last time modified
What does xargs
do? Give an example of how to use it.
xargs
will start its own command line and can be used to run commands in parallel by piping input from one command
to xargs. In the following example I will use xargs to open all files in the current path that have the .py extension:
find . -name "*.py" | xargs gedit