cd
cat
, ls
, mkdir
, mv
, rm
ls
vs ls -l
man
*
) to gather multiple files or directoriesterminal (aka, "terminal emulator) : a program that runs a shell [...?]
shell
: a program that allows a user to pass commands to the operating system of their computer
$ echo "Hello world!"
Hello world!
$
Type commands at the prompt $
. If you don't see the prompt, the computer is
still doing something.
The prompt shows basic login information followed by a $
or %
.
[USERNAME@NODE] $
In examples, you will often see only the dollar sign $
:
$ ls
Or just the command:
ls
command line interface (CLI)
: a program that takes text as input and displays text as output
shell
: a program that allows a user to pass commands to the operating system of their computer
terminal
: a program that runs a shell program inside of it
Linux
: an operating system
There are two ways to use the command line on ISAAC-NG:
ssh
via your computer's Terminal application (or similar). For more
information, see:
ssh
(optional)ssh
command to connect to ISAAC-NG:$ ssh <YOUR NETID>@login.isaac.utk.edu
yes
to accept the key.1
and then press the Enter key.In your shell, all commands are relative to the current working directory.
The pwd
command print the working directory.
Type the command pwd
at the prompt, then press the Return or
Enter key to run it.
$ pwd
/nfs/home/jmill165
$
Type the command ls
at the prompt, then press the Return or
Enter key to run it:
On my personal machine:
$ ls
Applications Library Public
Desktop Movies Videos
Documents Music
Downloads Pictures
$
On the cluster:
$ ls
[TODO]
$
Command | What it does |
---|---|
pwd |
print current working directory |
ls |
list files in the current working directory |
cat <filename> |
print the contents of the file <filename> |
head <filename> |
first 10 lines of <filename> |
tail <filename> |
last 10 lines of <filename> |
wc <filename> |
number of characters, words, and lines in <filename> |
grep <query> <filename> |
search <filename> for text <query> |
history |
your command history |
echo <your text> |
print <your text> to the terminal |
Command | What it does |
---|---|
cd |
change the current working directory to your home directory |
cd <dirname> |
change the current working directory to <dirname> |
mkdir <dirname> |
make directory <dirname> |
cp <source> <target> * |
create a copy of file <source> named <target> |
mv <source> <directory> * |
move <source> (file or directory) into <directory> |
mv <source> <target> ** |
rename <source> (file or directory) to <target> |
rm -i <filename> |
remove (delete*) file named <file> |
echo <your text> >> <filename> |
write <your text> to the file <filename> |
Special characters
Some characters do different things depending on the context. Be careful before typing running commands with these characters:
. / > \ | ~ * $
... and many more!
* Be careful not to overwrite existing files when using cp
and mv
.
** There is no "trash" or "recycle bin"!!! You cannot recover deleted files.
cd /lustre/isaac24/scratch/<netid>
$ mkdir example
$ ls
example
cd
$ cd example
$ pwd
/nfs/home/jmill165/example
cd
cd
to your scratch directory.
Variables begin with a dollar sign $
and are often (but not always) typed
in all uppercase:
$ cd $SCRATCHDIR
$ pwd
/lustre/isaac24/scratch/jmill165
cd
cd
to your home directory
$ cd
$ pwd
/nfs/home/jmill165
cd
cd
back to the directory you were in previously
$ cd -
$ pwd
/lustre/isaac24/scratch/jmill165
Check out this bash Cheatsheet
List the contents of your home directory with extra information:
$ ls -l /nfs/home/NETID
^^ option
^^^^^^^^^^^^^^^ argument
SCRATCHDIR
variable.foo.txt
rm foo.txt
... what happens?bar
rm bar
... what happens?
rm
for deleting files.rmdir
to delete empty directories (safer option).rm -r
to delete directories and their contents (use with caution!).Absolute path
cd
mkdir foo bar
cd /nfs/home/<netid>/foo
cd /nfs/home/<netid>/bar
cd ~
cd /lustre/isaac24/scratch/<netid>
cd $SCRATCHDIR
Relative path
cd
mkdir foo bar
cd foo
cd ../bar
.
: The current working directory
..
: The parent directory relative to the current working directory
ls -la
.<something>
: A hidden file or directory
cd /lu<TAB>
cd /lustre
cd /lustre/<TAB>
???
*
cd
touch foo bar buzz
echo f*
echo b*
Use echo
to test commands:
echo rm b*
If it looks good, just use the up arrow to show the command again, then delete
the echo
.
Manual man
pages and less
man cp
(Or Google linux man cp
.)
Manual man
pages will open in a program called less
. Use the arrows to
scroll up/down, and type q to quit. Type ? for help.
Q: What command line options could you use with cp
, mv
to avoid
accidentally overwriting files?
Q: What command line options could you use with rm
to avoid accidentally
deleting files?
... to a file and append to the file (if it exists, otherwise, create it):
echo "foo bar" >> foo.txt
... to a file and OVERWRITE that file:
echo "foo bar" > foo.txt
... to another command:
echo "foo bar" | grep foo
tmp
directory and cd
into it.a
, b
, and c
, and add some sample text to each one.cp a b
...
mv a c
...
$ echo aa > a ; echo bb > b ; echo cc > c
$ ls
a b c
$ cat *
aa
bb
cc
$ cp a b
$ ls
a b c
$ cat *
aa
aa
cc
$ mv a c
$ ls
b c
$ cat *
aa
aa