Command Line Tips

Basic Tips

Here are some tips to get started with the command line in your FreeBSD jail:

  • When you enter your password the cursor will not move (or blink). This is for security reasons, namely that someone looking over your shoulder won’t know how many characters your password is.
  • To learn more information about a command run the man program. For example, to learn more about the cp program you can run man cp to get to know more about it.
  • Commands are case sensitive. Make sure to be careful when entering them and pay attention to detail.
  • If you get stuck take a screen shot and send it to your instructor for help. Make sure that you explain what you were trying to achieve and what the previous steps were.
  • Learn the basic commands that are listed below.

Overview of Commands

Here are some basic commands:

Command Description
pwd prints working directory
ls lists contents of current directory
ls –l lists contents of current directory with extra details
cd ~ change directory to your home directory
cd name change directory to name
cd .. change directory to parent directory (using a relative path)
cd /some/path change directory to /some/path (using an absolute path)
cd – change to the previous directory you were in
mkdir name create directory name
rmdir name remove directory name (must be empty)
touch name create empty file name or changes timestamp if it already exists
cp file1 file2 copy file1 to file2 (file2 will be overwritten)
rm file remove file file
rm –f file force removal of file file (no confirmation)
cp –r dir newdir copy directory dir to newdir recursively
rm –rf dir force removal of directory dir recursively (use with caution!)
cat file.txt display the contents of file.txt
more file.txt display the contents of file.txt screen by screen, spacebar to scroll, q to quit
head file.txt display first 10 lines of file.txt
tail file.txt display last 10 lines of file.txt
tail –f file.txt display the contents of file.txt as it grows, ctrl-c to quit
mv fileordir dir move fileordir into dir
mv file newname rename file to newname (will be overwritten if already exists)
top displays all the processes running on the machine, and shows available resources
date shows the current date and time
ctrl-c kill the running program