Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

2) The Linux Filesystem and commands

Last time:

  • Reproducibility and git

  • Intro to Julia and its package management

Today:

  1. The Linux Filesystem

  2. Some basic Linux 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.

DirectoryDescription
/Root directory of the entire file system
/binEssential command binaries needed for single-user mode
/bootBoot loader files (e.g., kernels)
/devDevice files (e.g., keyboard, mouse, etc; convenient to back up)
/etcSpecific system-wide configuration files
/homeUsers’ home directories, containing saved files, personal settings, etc.
/libLibraries essential for binaries in /bin and /sbin
/mediaMount points for removable media (e.g., CD-ROMs)
/mntTemporarily mounted file systems
/optAdd-on application software packages (e.g., Word Procs, Accounting soft, etc.)
/rootHome directory for the root user
/runInformation about the running system since last boot
/sbinEssential system binaries (e.g., fsck equivalent to Windows CHKDSK)
/srvSite-specific data served by the system (e.g., Web servers data and scripts, etc.)
/sysInformation about devices, drivers, some kernel features
/tmpTemporary files (usually not preserved between system reboots)
/usrSecondary hierarchy for read-only user data (e.g., multi-user utilities and applications)
/varFiles whose context is expected to continually change during normal operation of the system (e.g., logs, spool files, etc.)

2. Some basic Linux commands

CommandMeaning
Ctrl lClean screen (keeps command history)
resetInitialize terminal
Ctrl AMove cursor to the beginning of command line
Ctrl EMove cursor to the end of command line
lsList current working directory content
ls -lList permission strings and other info
ls -tSort files and directories by their last modification time (most recently modified first)
ls *.txtList all files with txt extension
ls -alList all files (including hidden files)
ls -l /List files in root directory
pwdPrint 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/dir3Create a parent directory dir1/dir2/dir3 (three levels deep)
rm file1 ... fileNRemove files file1, ..., fileN
rm -r dirRemove directory dir and its content recursively
mvMove or rename existing files/directories
cat file1 ... fileNConcatenate files file1,...,fileN and print result
touch file1 ... fileNCreate empty files or edit existing file
./<command>Execute a local command/program/script
chmod fileChange file permissions
man <command>See documentation of any <command>

Exercise 2.1

Print the current working directory

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