Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Useful Unix Commands Cheat Sheet , Cheat Sheet of Operating Systems

All-in-one cheat sheet on the main Unix Commands

Typology: Cheat Sheet

2019/2020

Uploaded on 10/23/2020

ekassh
ekassh 🇺🇸

4.7

(23)

274 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Useful Unix Commands Cheat Sheet
PHYS3061 Introduction to Computer Simulations of Physical Systems (Spring 2018)
FILE MANIPULATION
ls List directories and files here
ls dir List directories and files in a directory
ls -a List all files including hidden files
ls -lh List including more data in readable
format
pwd Return path to working directory
cd dir Change directory
cd .. Go to parent directory
cd / Go to root directory
cd ~ Go to home directory
cd Go to home directory
touch file Create en empty file
cp file1 file2 Copy file1 to file2
cp -r dir1 dir2 Copy dir1 to dir2 including
subdirectories
rm file Remove a file
rm -r dir Remove a directory and its files
mv dir1 dir2 Move or renames a file
mkdir dir Make a directory
rmdir dir Remove a directory
locate file Search a file
OTHERS
man command Show command usage
top Show process activity continuously
top -n1 Show process activity once
command > file Save STDOUT in a file
command >> file Append STDOUT in a file
[Tab] Autocomplete or hints
icc main.c Compile C code
icpc main.cpp Compile C++ code
ifort main.f Compile Fortran code
TEXT PROCESSING
cat file1 file2 > file3 Merge files 1 and 2 into file3
head file Print first lines from a file
head -n 5 file Print first 5 lines from a file
tail file Print last lines from a file
tail -n 5 file Print last 5 lines from a file
less file View a file
less -N file View file with line numbers
less -S file View file, wrap long lines
grep ‘pattern’ file Print lines matching a pattern
grep -c ‘pattern’ file Count lines matching a pattern
cut -f 1,3 file Retrieve data from 1,3 columns
in a tab-delimited file
sort file Sort lines from a file
sort -u file Sort and return unique lines
uniq -c file Filter adjacent repeated lines
wc file Count lines, words and bytes
COMPRESSION
tar -cf file.tar dir Group files
tar -xf file.tar Ungroup files
tar -zcf file.tar.gz dir Group and compress files
tar -zxf file.tar.gz Extract and ungroup files
REMOTE ACCESS
wget url Download a file
ssh user@server Connect to a server
scp -r local_dir
user@server:remote_dir
Copy file from local to
remote computer
scp -r user@server:remote_dir
local_dir
Copy file from remote
to local computer

Partial preview of the text

Download Useful Unix Commands Cheat Sheet and more Cheat Sheet Operating Systems in PDF only on Docsity!

Useful Unix Commands Cheat Sheet

PHYS3061 Introduction to Computer Simulations of Physical Systems (Spring 2018 )

FILE MANIPULATION

ls List directories and files here ls dir List directories and files in a directory ls -a List all files including hidden files

ls -lh List including more data in readable format pwd Return path to working directory cd dir Change directory cd .. Go to parent directory cd / Go to root directory cd ~ Go to home directory cd Go to home directory touch file Create en empty file cp file1 file2 Copy file1 to file

cp -r dir1 dir

Copy dir1 to dir2 including subdirectories rm file Remove a file rm -r dir Remove a directory and its files mv dir1 dir2 Move or renames a file mkdir dir Make a directory rmdir dir Remove a directory locate file Search a file

OTHERS

man command Show command usage top Show process activity continuously top -n1 Show process activity once command > file Save STDOUT in a file command >> file Append STDOUT in a file [Tab] Autocomplete or hints icc main.c Compile C code icpc main.cpp Compile C++ code ifort main.f Compile Fortran code

TEXT PROCESSING

cat file1 file2 > file3 Merge files 1 and 2 into file head file Print first lines from a file head -n 5 file Print first 5 lines from a file tail file Print last lines from a file tail -n 5 file Print last 5 lines from a file less file View a file less -N file View file with line numbers less -S file View file, wrap long lines grep ‘pattern’ file Print lines matching a pattern grep -c ‘pattern’ file Count lines matching a pattern

cut -f 1,3 file Retrieve data from 1,3 columns in a tab-delimited file sort file Sort lines from a file sort -u file Sort and return unique lines uniq -c file Filter adjacent repeated lines wc file Count lines, words and bytes

COMPRESSION

tar -cf file.tar dir Group files tar -xf file.tar Ungroup files tar -zcf file.tar.gz dir Group and compress files tar -zxf file.tar.gz Extract and ungroup files

REMOTE ACCESS

wget url Download a file ssh user@server Connect to a server scp -r local_dir user@server:remote_dir

Copy file from local to remote computer scp -r user@server:remote_dir local_dir

Copy file from remote to local computer