Unix Commands Supplemental and Summary

Accessing NFS

Windows

PuTTY

http://simms-teach.com/howtos/images/103-putty-icon.jpg

  • Type the following for Host-name:remote.eos.ncsu.edu
  • Click “Linux”
  • Click “Save”
  • Click “Open”
  • Login using your Unity ID – Hit “Enter”
  • Type your password
    • ***Note: it will look like you are not typing, but this is just a security feature
  • Hit “Enter”

Mac/Linux Finder

Terminal

http://png-3.findicons.com/files/icons/2166/oxygen/128/utilities_terminal.png

  • Type the following:
    • ssh unityid@remote.eos.ncsu.edu
    • Make sure you use your Unity ID

  • Type your password
    • ***Note: it will look like you are not typing, but this is just a security feature
  • Hit “Enter”


Helpful Shortcuts in the Terminal

  • Up and Down arrows

    • Used to scroll through commands

  • Tab completion

    • Used for long file names

  • Chaining ;

    • Used for combining multiple commands

    • Example: cd ~/ ; pwd ; ls

  • The clear command. type in the word clear and watch the screen adjust up so that you have a clean screen!

Smartphone Analogy

Voice Commands: Call my Dad’s Cell phone (Smartphone Analogy)

  • Go to voice commands
  • Find and use the right command
    • Ex: Call
    • Ex: Text (send a message?)
  • Find the right person
    • Ex: Dad
  • Are there options?
    • Ex: which number: cell (not required , used to provide extra information)
  • Putting it all together: Call Dad’s Cell

Terminal Commands:
List the contents of ~/ with details

  1. Connect to terminal
  2. Find and use the right
    command:
  • Ex: ls (list contents)
  • Ex: script (create a log file)
  1. Find the right path
  • Ex: ~/
  1. Are there options? • Ex: want details: -l
    (not required, used to provide
    extra information)
  2. Putting it all together: ls -l ~/

Standard Syntax

Standard command line format:

eos$ command –options argument_1 argument_2

where…

  • eos$ is the prompt and is simply the marker for which system you are logged into. This is not part of the command line.
  • command is the command you wish to use
  • –options are used to modify the behavior of the command
  • argument_1 and argument_2 are the parameters of the command

VERY IMPORTANT…

eos$ is NEVER part of the syntax of a command… it is just a marker for the command prompt, so that you know where to input the command.

On some machines… it might even say something_else%, so do not be alarmed if you don’t have eos$.

HOWEVER… when asked a question about the syntax of a command, or when asked to write what you typed in the terminal window, eos$ should NEVER be part of the answer and you will receive a deduction for each instance.

Print working directory: pwd

Command: pwd

Syntax:

eos$ pwd

  • Used for determining the user’s current location in the file tree

Should you expect output? Yes

What is the output? the absolute pathname of the user’s current directory

Log File: script

Command: script

Syntax:

eos$ script -options logfilename.txt

  • Options:
    • -a : append. Allows you to append a log file
    • -f : flushed. Writes to the file in real time. You should always use this option in E 115
  • Note: To end a log file, you must type “exit”.
  • The log file will create wherever you were when you executed the command.

Should you expect output? Yes

What is the output? Will tell you the file has started. Upon exit, will tell you the file is finished.

WHEN YOU ARE DONE: EXIT your log file and then always type logout to end your terminal session.

List the contents of a directory: ls

Command: ls

Syntax:

eos$ ls -options location/directory

  • Used to list the contents of a specific directory
  • Options:
    • -a : all. shows all files, including hidden ones
    • -l : long. shows files in long format plus details
    • Options can be used in any order or used independently of each other

Should you expect output? Yes

What is the output? the contents of the directory specified, OR of the current directory if nothing is specified

I want to list the contents of my HOME directory using a relative path name…

I am in my home directory, ~/
I am elsewhere in the file tree

  • ls
    or
    ls -a 
    (only if asked for all files)
    or
    ls -l
    (only if asked for info on files)
    or
    ls -al or ls -la
    (only if asked for all files with details)
  • ls ~/
    or
    ls -a ~/
    or
    ls -l ~/
    or
    ls -al ~/ or ls -la ~/

Make Directory: mkdir

Command: mkdir

Syntax:

eos$ mkdir location/directory

  • Used to create a new directory
  • Options:
    • -p : creates every directory in the pathname, assuming it doesn’t already exist
    • If you are in the location, you can ignore that part of the syntax
    • The terminal window is very literal, so make sure you either specify an exact location or be in that location.

Should you expect output? No

Advice: use pwd or ls with or after using cd to ensure you’ve done it right.

I want to create a directory named MyE115 in my home directory…

I am in ~/
I am elsewhere in the file tree

  • mkdir MyE115
    the terminal is CASE SENSITIVE
    do an ls after to ensure proper creation
  • mkdir ~/MyE115
    the terminal is CASE SENSITIVE and there is NO SPACE between the ~/ and the name of the directory
    do an ls ~/ after to ensure proper creation

Change directory: cd

Command: cd

Syntax:

eos$ cd newdirectory

  • Used to change your current location

Should you expect output? No

Advice: use pwd or ls with or after using cd to ensure you’ve done it right.

Copy files: cp

Command: cp

Syntax:

eos$ cp location/file.ext newlocation

  • Used to copy a file from one location to another
  • Also used to rename files and keeps the original

Should you expect output? No

Advice: use ls with or after using cd to ensure you’ve done it right.

I want to copy a file named example.txt from my HOME directory to my ~/MyE115 directory…

I am in ~/
I am elsewhere in the file tree

  • cp example.txt MyE115
    or
    cp example.txt MyE115/newName.txt
    do an ls after to ensure proper copying
  • cp ~/example.txt ~/MyE115
    or
    cp ~/example.txt ~/MyE115/newName.txt
    do an ls after to ensure proper copying

Move files: mv

Command: mv

Syntax:

eos$ mv location/file.ext newlocation/newName.ext

  • Used to move a file from one location to another
  • Also used to rename files and deletes the original

Should you expect output? No

Advice: use ls with or after using cd to ensure you’ve done it right.

Cannot be used within the E 115 course locker

Students lack the permission (will talk more in depth about permissions next lecture)

I want to move a file named example.txt from my HOME directory to my ~/MyE115 directory…

I am in ~/
I am elsewhere in the file tree

  • mv example.txt MyE115/newName.txt
    do an ls after to ensure proper moving
  • mv ~/example.txt ~/MyE115/newName.txt
    do an ls after to ensure proper moving

Remove files or folders: rm

Command: rm

Syntax:

eos$ rm -options location/file.ext

  • Used to delete files or folders from the system
  • Options:
    • -r : recursive. Required for deleting directories
    • -f : forced. deletes without asking permission

Should you expect output? Only if you don’t use -f

What is the output? asks if you want to remove the file or folder in question

Removing files and folders: an example

I am in ~/ and so is file.txt and folder

Files

  • rm file.txt
    or
    rm -f file.txt

Folders

  • rm -rf folder
    *be careful when using -f!!

I am elsewhere in the file tree and file.txt and folder are in ~/
Files

  • rm ~/file.txt
    or
    rm -f ~/file.txt

Folders

  • rm -rf ~/folder
    *be careful when using -f!!

Manual pages: man

Command: man

Syntax:

eos$ man command

  • To scroll, use the arrow keys. To exit, press q
  • Used for learning more information on given command

Should you expect output? Yes

What is the output? The contents of the manual page for the question