Site Map Online Directory
  Search Information Technology   Northwestern University  
YOU ARE HERE >   NUIT > SSCC > HOWTOs > Basic LINUX Commands
Basic LINUX Commands

About the SSCC

Cluster Report (NU Restricted)

HOWTOs

Bulletins

Statistical Software

Statistical Software Manuals

Additional Resources

Migration Information

Social Science Data Services

Kellogg Research Computing

Depot File Service

Improving Social Science Research Computing (PDF)

Contact List

Services

Get Connected

Support

Educational Resources

NUIT

Basic LINUX Commands

printer friendly format

Here are some basic commands that you need to work on the cluster. In these examples the commands themselves are highlighted in yellow and are followed by the output they produce.

ls : list files in a directory
pwd : show full path to current directory
mkdir : make directories
cd : change directory
cp : copy files and directories
rm : remove files
rm -rf : remove a directory and everything in it
man : show usage manual for a command
* ? and other wildcards
~ : shortcut to your home directory

 

ls : list files in a directory

Back to top

Simple file listing:

[abc123@seldon abc123]$ ls
figure1.fig  test.m  test.sh

Display extra details (file size, type, date, permissions) with the "long" (-l) option:

[abc123@seldon abc123]$ ls -l
total 12
-rw-------    1 abc123   users        1121 Oct 30 16:15 figure1.fig
-rw-------    1 abc123   users          69 Oct 30 16:15 test.m
-rwx------    1 abc123   users          40 Oct 30 16:10 test.sh

You can use wildcards to select only some of the files.

[abc123@seldon abc123]$ ls -l test*
-rw-------    1 abc123   users          69 Oct 30 16:15 test.m
-rwx------    1 abc123   users          40 Oct 30 16:10 test.sh

 

pwd : show full path to current directory

Back to top

Print working directory path:

[abc123@seldon abc123]$ pwd
/sscc/home/a/abc123

 

mkdir : make directories

Back to top

Create a new subdirectory called subdir in the current directory:

[abc123@seldon abc123]$ mkdir subdir
[abc123@seldon abc123]$ ls -l
total 16
-rw-------    1 abc123   users        1121 Oct 30 16:15 figure1.fig
drwx------    2 abc123   users        4096 Nov  4 13:55 subdir
-rw-------    1 abc123   users          69 Oct 30 16:15 test.m
-rwx------    1 abc123   users          40 Oct 30 16:10 test.sh

 

cd : change directory

Back to top

Switch to a subdirectory called subdir in your current directory:

[abc123@seldon abc123]$ cd subdir
[abc123@seldon subdir]$

Two dots .. denote one directory up in your path:

[abc123@seldon subdir]$ cd ..
[abc123@seldon abc123]$

To use the full path start with a slash:

[abc123@seldon abc123]$ cd /datalib/cps
[abc123@seldon cps]$ pwd
/datalib/cps

 

cp : copy files and directories

Back to top

Syntax:

cp [options]... Source Destination
cp [options]... Source... Directory

Options:

-i : prompt before overwriting files
-r : copy recursively (copy subdirectories and their contents)
-u : overwrite destination files only when the source file is newer
-v : show what is being done

Make a copy of a file called make.do with a different name:

[abc123@seldon abc123]$ cp -v make.do make2.do
`make.do' -> `make2.do'

Copy one or more files to another directory:

[abc123@seldon abc123]$ cp -v *.do subdir/
`make.do' -> `subdir/make.do'
`make2.do' -> `subdir/make2.do'

Copy the contents of a directory and its subdirectories to another place:

[abc123@seldon abc123]$ cp -vR subdir/* subdir2/
`subdir/make.do' -> `subdir2/make.do'
`subdir/make2.do' -> `subdir2/make2.do'
`subdir/data/file.dat' -> `subdir2/data/file.dat'

 

rm : remove files

Back to top

Remove a file called make.do:

[abc123@seldon abc123]$ rm make.do

To remove a file with spaces in its name, use quotes:

[abc123@seldon abc123]$ rm "file name.txt"

To remove multiple files (or to save time typing long file names) use wildcards. Be careful - wildcards are powerful and could match more files than you intended. Use the ls command first to check what files will be deleted.

[abc123@seldon abc123]$ rm *.txt

 

rm -rf : remove a directory and everything in it

Back to top

Delete a subdirectory called subdir and all of its contents (including its subdirectories).

[abc123@seldon abc123]$ rm -rf subdir

 

man : show usage manual for a command

Back to top

Display a more detailed manual for a command:

Press <Space bar> to view the next page
Press q to exit
[ate533@seldon ate533]$ man cp
CP(1)                                 FSF                                CP(1)

NAME
       cp - copy files and directories

SYNOPSIS
       cp [OPTION]... SOURCE DEST
       cp [OPTION]... SOURCE... DIRECTORY
       cp [OPTION]... --target-directory=DIRECTORY SOURCE...

DESCRIPTION
       Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.

                                     . . .

 

* ? and other wildcards

Back to top

You can use these powerful wildcards with any command that takes filenames as an argument. For example prog??.* will match all files with names that start with prog followed by any two characters, a dot, and anything (or nothing) following the dot.

WildcardMatches
*zero or more characters
?exactly one character
[abxy]exactly one character from the list (a, b, x or y)
[a-e]exactly one character in the given range (a, b, c, d or e)
[!abxy]any character that is not listed
[!a-e]any character that is not in the given range
{beef,fish,tofu}exactly one entire word from the list in curly brackets (beef, fish or tofu)

 

~ : shortcut to your home directory

Back to top

You can reference your home directory in your commands and programs with the character tilde ~ shortcut. If your home directory is

/sscc/home/a/abc123
then instead of writing out the full path to the file
/sscc/home/a/abc123/data/input.dat
you can just write
~/data/input.dat

Computer and Network Security

E-mail, NetID, and Password

Hardware

Listserv

Network Services

NUTV and TV Services

Policies and Guidelines

Reserve a Facility

Service Status

Software

Telephone Services

Videoconferencing Services

Web Publishing Services

Webcasting

Webmail

Off-campus Connections

Safe access to the NU Network (VPN)

Wired Connection

Wireless access

Departmental Desktop and Server Support

NUIT Help

Student Support

Computer Labs

Course Management System (Blackboard)

Learning Opportunities

Smart Classrooms

about NUIT

Job Opportunities in NUIT

News, Press, and Publications

What's New & Changing with Technology @ NU?