2) The Linux Filesystem and commands

2) The Linux Filesystem and commands#

  1. The Linux Filesystems

  2. Introduction to some Linux bash commands

1. The Linux Filesystem#

The Linux file system can intended in two ways: the directories tree that describes the file organization/structure and the format that defines how files are stored on disk (FAT32, ext4, etc). In this class, we will talk about the default layout of the directories tree on a Linux system.

Tip

Check this very useful resource on The Linux Filesystem

Directory

Description

/

Root directory of the entire file system

/bin

Essential command binaries needed for single-user mode

/boot

Boot loader files (e.g., kernels)

/dev

Device files (e.g., keyboard, mouse, etc; convenient to back up)

/etc

Specific system-wide configuration files

/home

Users’ home directories, containing saved files, personal settings, etc.

/lib

Libraries essential for binaries in /bin and /sbin

/media

Mount points for removable media (e.g., CD-ROMs)

/mnt

Temporarily mounted file systems

/opt

Add-on application software packages (e.g., Word Procs, Accounting soft, etc.)

/root

Home directory for the root user

/run

Information about the running system since last boot

/sbin

Essential system binaries (e.g., fsck equivalent to Windows CHKDSK)

/srv

Site-specific data served by the system (e.g., Web servers data and scripts, etc.)

/sys

Information about devices, drivers, some kernel features

/tmp

Temporary files (usually not preserved between system reboots)

/usr

Secondary hierarchy for read-only user data (e.g., multi-user utilities and applications)

/var

Files whose context is expected to continually change during normal operation of the system (e.g., logs, spool files, etc.)

2. Some basic Linux commands#

Tip

Check this very useful resource on Linux command line for beginners

Command

Meaning

Ctrl l

Clean screen (keeps command history)

reset

Initialize terminal

Ctrl A

Move cursor to the beginning of command line

Ctrl E

Move cursor to the end of command line

ls

List current working directory content

ls -l

List permission strings and other info

ls -t

Sort files and directories by their last modification time (most recently modified first)

ls *.txt

List all files with txt extension

ls -al

List all files (including hidden files)

ls -l /

List files in root directory

pwd

Print current working directory

cd /

Change working directory to root

cd ..

Change working directory one level up

cd -

Get back to previous directory

cd ~

Short hand for your home directory

mkdir <dir_name>

Create new directory dir under current directory

mkdir {dir1,...,dirN}

(no spaces) Create new directories dir1, … , dirN under current dir

mkdir -p dir1/dir2/dir3

Create a parent directory dir1/dir2/dir3 (three levels deep)

rm file1 ... fileN

Remove files file1, …, fileN

rm -r dir

Remove directory dir and its content recursively

mv

Move or rename existing files/directories

cat file1 ... fileN

Concatenate files file1,…,fileN and print result

touch file1 ... fileN

Create empty files or edit existing file

./<command>

Execute a local command/program/script

chmod file

Change file permissions

man <command>

See documentation of any <command>

Exercise 2.1

Print the current working directory

Tip

If you want to use any shell commands in your Julia Jupyter notebook, you can simply change the mode of the Julia REPL by prepending ; to your command.

Exercise 2.2

Create a new directory and move into it

Exercise 2.3

Now that you have created a directory, initialize a git repository (Exercise 1.1. from last class)

Exercise 2.4

Delete the newly created directory