Ubuntu Terminal Usage

If you are not familiar with the use of terminal you must learn it for this course. You can watch the video below prepared for the Computer Programming course. You can follow the video with this repository.

To remind you, the basic commands are given as follows.

Command Funcitonality Example Usage
cd change directory cd ~, cd /home/btu, cd /opt/openfoam10/tutorials
mkdir make directory mkdir -p lecture_01, mkdir -p car_case
cp copy files/folders cp -r lecture01 lecture_01, cp -r car_case carCase
rm remove files/folders rm -rf carCase
touch make dummy file touch a.txt
cat print content of a file cat a.txt
ls list directory contents ls, ls -l, ls -a
mv move or rename files/folders mv old_name.txt new_name.txt, mv file.txt /path/to/destination
pwd print working directory pwd
echo display a line of text echo "Hello World"
grep search text using patterns grep 'word' filename, grep -r 'word' /path/to/directory
find search for files in a directory hierarchy find / -name filename.txt
chmod change file mode bits chmod +x script.sh
chown change file owner and group chown user:group file
tail output the last part of files tail -n 5 file.txt
head output the first part of files head -n 5 file.txt
diff compare files line by line diff file1.txt file2.txt
tar archive utility tar -czvf archive.tar.gz /path/to/directory
gzip compress or expand files gzip file, gzip -d file.gz
unzip extract compressed files in a ZIP archive unzip file.zip
wc print newline, word, and byte counts for each file wc filename.txt
sort sort lines of text files sort file.txt
uniq report or omit repeated lines uniq file.txt
which locate a command which python
df display disk space usage df -h
du estimate file space usage du -sh /path/to/directory
exit exits the terminal exit
screen dividing terminal into windows screen -S cfd + ctrl+z S and ctrl+z \| for division

Some other commands which make terminal use useful are as follows:

Command Funcitonality
find $WM_PROJECT_DIR -type d -name '*fvPatch*' finds directories containing the string fvPatch in a file name
find $WM_PROJECT_DIR -type f -name '*fvPatch*' finds files containing the string fvPatch in it
find $FOAM_TUTORIALS -type f \| xargs grep -sl ' slip' finds tutorials using slip condition
find $FOAM_SRC -name '*slip*' finds the source code where the slip boundary condition is located
find $WM_PROJECT_DIR -type f \| xargs grep -sl 'noParallel' finds which applications do not run in parallel