Software‎ > ‎Tutorials‎ > ‎

linux commands

Basic Basic Linux/Unix

 

In linux your location (or the location of files) is known as a path. Paths on linux are either relative or absolute. Absolute paths begin with / (a.k.a. root). Relative paths start implicitly in the present working directory (.). A path can then append directories or files to the present working directory. There are a couple special directories: the parent directory (..) of any directory and your home directory (). Table 1.2 shows some basic path symbols.

Table 1.1: Basic linux commands

 

Path

Notes

/

Root dir

.

Present dir

..

Parent dir

../..

Parent's parent dir

User's home dir

 

 

Linux commands are typed in a terminal to cause some action. Many commands have arguments denoted by words following a command. A common argument is a path that uniquely identifies a directory (dir) or file. Many commands also have options denoted by a hyphen and a letter. When an option or argument is optional it is shown in square braces. Some common commands are listed in Table 1.2.

We also recommend the UNC ITS LearnIT program1. This program provides a portal to opportunities for faculty, staff, and students to learn about the use of information technology (IT) to increase productivity and to engage in discussions about technology's role and impact on the University mission. We recommend the following courses be taken to complete this section of the training2.

Introduction to HPC, a Research Computing Server

Linux: Introduction at Software Carpentry

Linux: Intermediate at Software Carpentry

Shell Scripting  at Software Carpentry

 

Table 1.2:

Basic linux commands

Description

Example Usage

Explanation

Manual for any command

man man

get manual for man

List contents

ls  /

look at contents of home directory

Update usage stats

touch old.txt

make a new file by updating its stats

Copy

cp old.txt new.txt

create a copy of old.txt named new.txt

Make dir

mkdir stuff

make a directory named stuff

Move

mv new.txt stuff/

move new.txt to stuff folder

Tape archive utility

tar cf stuff.tar stuff

create a tape archive version of stuff

Compress

zip stuff.tar.gz stuff.tar

compress the tape archive version of stuff

Change dir

cd stuff

change directory to new stuff

Show current dir

pwd

display the current directory

Remove file

rm new.txt

remove new.txt file

Change dir

cd ..

change directory to parent of current

Remove dir

rmdir ./stuff

delete folder named stuff

Text reader

less old.txt

show contents (empty)

Text editor

nano old.txt

show contents and allow edits

Uncompress and restore tape archvie

tar -xf stuff.tar

restore stuff from tape archive file

Move

mv stuff newstuff

move ./stuff to ./newstuff

Unzip

unzip old.txt.zip

uncompress old.txt

Remotely copy

scp stuff.tar.gz gatorid@submit.hpc.ufl.edu: /

copy compressed tar file to your home directory on hpc

Remotely connect to emerald

ssh gatorid@submit.hpc.ufl.edu.unc.edu

create a secure connection to hpc

Uncompress and restore zipped tape archvie

tar -xzf stuff.tar.gz

restore stuff from compressed tape archive file

exit

exit

exit connection to hpc

Make directory

mkdir oldstuff

make a new folder name oldstuff

Sync 2 dir

rsync -a gatorid@submit.hpc.ufl.edu: /stuff oldstuff

 

Comments