Finding your way around the disk and the files on it.
Marek Šuppa
Ondrej Jariabka
Adrián Matejov
lscpu -e
display information about available CPU
-e
makes the output a bit less verbose and a bit more "human readable"
lscpu -e
display information about available CPU
-e
makes the output a bit less verbose and a bit more "human readable"
free
lscpu -e
display information about available CPU
-e
makes the output a bit less verbose and a bit more "human readable"
free
top
/ htop
lspci
lsusb
lsblk
-f
flag makes the output show a bit more about the filesystem (like its type or usage)Massive variability:
floppy disk
CD / DVD
network disk (Samba, NFS, ...)
hard disk
USB disk (of various types)
Allows one big disk to be "logically" partitioned to smaller subparts
These partitions are handled as "independed disks"
Allows for specific parts of the filesystem to be dealt with differently
Separate user data from system files
Different filesystem types on different partitions
Image from Wikipedia
A way of managing
where a piece of data starts and finishes on a block device (disk)
what its name is (filename), when was it created, ...
where can the user find it (what directory does it reside in)
on a specific device (i.e. optical discs vs. Flash discs vs. hard discs)
A way of managing
where a piece of data starts and finishes on a block device (disk)
what its name is (filename), when was it created, ...
where can the user find it (what directory does it reside in)
on a specific device (i.e. optical discs vs. Flash discs vs. hard discs)
Standard file system types you are likely to encounter:
All the other (non-root) "data devices" are connected in so called "mountpoints"
Once the device is mounted, the directory contains its contents
This is in contrast to "disks" (separate partitions) on Windows (with names like C:\
, D:\
and so on)
graph TD root("/") root --> boot("boot") root --> dev("dev") root --> media("media") media --> cdrom[cdrom] media --> usb["USB"] root --> proc("proc") root --> etc("etc") root --> usr("usr") usr --> usrbin("bin") root --> bin("bin") root --> home("home") home --> jane("jane") jane --> Documents jane --> Downloads jane --> Photos jane --> Music Documents --> homework([homework.txt]) root --> tmp("tmp")
/home
The home directories of system's users
/home/jane
Contains various user data, configuration files, possibly even user's applications
/home
The home directories of system's users
/home/jane
Contains various user data, configuration files, possibly even user's applications
Also denoted via the tilda ~
sign (which you see after you log in)
/home
The home directories of system's users
/home/jane
Contains various user data, configuration files, possibly even user's applications
Also denoted via the tilda ~
sign (which you see after you log in)
Prepended to a username, it indicates that user's home directory
~jane
would mean /home/jane
in our exampleThe tilda sign is a nice example of how the realities of where technologies were created shape various decisions we live with even now.
Here is what the Wiki says:
This convention derives from the Lear-Siegler ADM-3A terminal in common use during the 1970s, which happened to have the tilde symbol and the word "Home" (for moving the cursor to the upper left) on the same key.
/etc
From the Latin et cetera (and so on)
Configuration of the whole system
Things you can find here:
scripts that are executed on system startup
list of users and their encrypted passwords
network settings
list of available shells
filesystem settings (i.e. where to mount which disk)
...
/etc
From the Latin et cetera (and so on)
Configuration of the whole system
Things you can find here:
scripts that are executed on system startup
list of users and their encrypted passwords
network settings
list of available shells
filesystem settings (i.e. where to mount which disk)
...
/proc
Information about the system and the processes running on it in the form of text files
/proc
folder/proc
Information about the system and the processes running on it in the form of text files
/proc
folder/proc/version
: version of the system that's running
/proc/cpuinfo
: information about CPU
/proc/meminfo
: information about RAM
/boot
Files (and directories) necessary for the system boot
Generally contains the kernel and sometimes the temporary filesystem that's being used before the kernel starts up
/bin
and /usr/bin
Both contain applications that can be executed from the command line
/bin
is reserved for system applications (like who
or whoami
)
/usr/bin
contains applications that are not system-critical (like a webbrowser for instance)
/bin
and /usr/bin
Both contain applications that can be executed from the command line
/bin
is reserved for system applications (like who
or whoami
)
/usr/bin
contains applications that are not system-critical (like a webbrowser for instance)
/usr
has many more interesting subdirectories; these generally contain files necessary for running the applications installed in /usr/bin
/tmp
Temporary files of the system and its users
These are not expected to "survive a reboot"
On Linux, this generally means that the files will not be written to disk but will stay in RAM
Generally implemented via tmpfs -- https://en.wikipedia.org/wiki/Tmpfs
/dev
As the name suggests, it contains "devices"
These behave as (special) files on the filesystem
There are two types
/dev
As the name suggests, it contains "devices"
These behave as (special) files on the filesystem
There are two types
Character devices
/dev/tty0
, /dev/input/by-path/platform-thinkpad_acpi-event
Block devices
/dev/sda1
, /dev/sda2
/dev
As the name suggests, it contains "devices"
These behave as (special) files on the filesystem
There are two types
Character devices
/dev/tty0
, /dev/input/by-path/platform-thinkpad_acpi-event
Block devices
/dev/sda1
, /dev/sda2
Also contains "pseudo devices"
/dev/null
: accepts and discards all input (basically your own black hole)/dev/random
: produces a continuous stream of random data$ mount [device] [folder]
so for instance
$ mount /dev/sdc /media/MyUSBKey
$ mount [device] [folder]
so for instance
$ mount /dev/sdc /media/MyUSBKey
$ umount [folder]
so for instance
$ umount /media/MyUSBKey
$ mount [device] [folder]
so for instance
$ mount /dev/sdc /media/MyUSBKey
$ umount [folder]
so for instance
$ umount /media/MyUSBKey
$ mount
Mounting is not necessary in normal usage: things like USB disks are being mount
ed automatically (hotplug)
Each disk will get its own temporary directory (on Fedora these are in /run/media/<USER>
, on other distros in /media
)
After the disk gets detached, the folder disappears (gets removed)
Mounting is not necessary in normal usage: things like USB disks are being mount
ed automatically (hotplug)
Each disk will get its own temporary directory (on Fedora these are in /run/media/<USER>
, on other distros in /media
)
After the disk gets detached, the folder disappears (gets removed)
Still, before detaching the disk, it is necessary to run umount
to ensure the data is written on it (or at least sync
)
df
df -h
-H
will give you powers of 1000df --total
pwd
ls
pwd
ls
cd [directory]
[directory]
pwd
ls
cd [directory]
change the current working directory (where you currently are in the filesystem) to [directory]
[directory]
can be both relative and absolute
pwd
ls
cd [directory]
change the current working directory (where you currently are in the filesystem) to [directory]
[directory]
can be both relative and absolute
cd # go to the home directorycd ~ # go to the home directorycd /home/jane/Documents # go to /home/jane/Documentscd .. # go one level abovecd Documents # go to the directory `Documents` in the current foldercd - # go to the previously visited directory
Absolute paths start from the the root (/
)
For instance /home/jane/Downloads/homework.pdf
or /usr/bin/whoami
No matter where you are on the disk, it will always resolve to the same place
Relative paths do not start from the root (/
) but they are resolved from the current working directory
.
represents the current directory and ..
the parent directory$ cd /home/joe$ cat Documents/homework.txtThis is joe's homework in /home/joe/Documents/homework.txt$ cd /home/jane$ cat ./Documents/homework.txtThis is jane's homework in /home/jane/Documents/homework.txt$ cd - # go to the previously visited directory$ pwd/home/joe
Files and folders whose name starts with a dot (.
) are ignored by ls
They still exist on the disk but to list them, one needs to use the -a
or -A
flag
$ lsa.txt b.txt c.txt data.dat test.txt$ ls -a. .. a.txt b.txt c.txt data.dat .hidden_file test.txt
Files and folders whose name starts with a dot (.
) are ignored by ls
They still exist on the disk but to list them, one needs to use the -a
or -A
flag
$ lsa.txt b.txt c.txt data.dat test.txt$ ls -a. .. a.txt b.txt c.txt data.dat .hidden_file test.txt
Note the first two "special paths" in the listing
.
represents current directory
..
represents parent directory
Files and folders whose name starts with a dot (.
) are ignored by ls
They still exist on the disk but to list them, one needs to use the -a
or -A
flag
$ lsa.txt b.txt c.txt data.dat test.txt$ ls -a. .. a.txt b.txt c.txt data.dat .hidden_file test.txt
Note the first two "special paths" in the listing
.
represents current directory
..
represents parent directory
These can also be chained together
$ cd ../../../../ # move four directories higher
aka "Don't type more than you need to"
Bash was written by "hackers" for "hackers": efficiency is one of its core tenants
It is not necessary to type out the full command name or the full path
After <Tab>
gets pressed, Bash will try to autocomplete the rest of the command or file path
Bash was written by "hackers" for "hackers": efficiency is one of its core tenants
It is not necessary to type out the full command name or the full path
After <Tab>
gets pressed, Bash will try to autocomplete the rest of the command or file path
If if there are multiple options, it will show them all
You can cycle through them by pressing <Tab>
(and cycle back with <Shift-Tab>
)
$ lsc<Tab>
will become
$ lscpu
and
$ cd Doc<Tab>
will become
$ cd Documents/
(provided you are a in a directory with a Documents/
directory in it.)
The history of all commands you type to Bash are (normally) being saved to ~/.bash_history
You can get to them by:
history
commandTo search in the history, start typing a command and then press Ctrl-r
(and Shift-Ctrl-r
to cycle through)
mkdir [directory]
[directory]
rmdir [directory]
[directory]
(if it's not empty, it'll let you know)mkdir [directory]
[directory]
rmdir [directory]
[directory]
(if it's not empty, it'll let you know)rm [file or directory]
removes a file or a directory
the -r
makes rm
also recursively apply itself on subfolders of its argument
$ rm -r /home/jane
would remove every file in /home/jane
, along with any directories and their content
cp [source1] [source2] [target]
copies files and folders from [source]
to [target]
there can be multiple sources
-r
makes cp
recursively copy the subfolders as well (it'll tell you otherwise)
cp [source1] [source2] [target]
copies files and folders from [source]
to [target]
there can be multiple sources
-r
makes cp
recursively copy the subfolders as well (it'll tell you otherwise)
mv [source1] [source2] [target]
moves files and directories from [source]
to [target]
there can be multiple sources
[source]
and [target]
can be any paths, relative or absolute, even the special ones like .
and ..
$ cd /home/jane$ cp -r /tmp/tests . # Recursively copies /tmp/tests to /home/jane$ cd /home/joe/Documents$ cp -r /tmp/tests .. # Recursively copies /tmp/tests to /home/joe
[source]
and [target]
can be any paths, relative or absolute, even the special ones like .
and ..
$ cd /home/jane$ cp -r /tmp/tests . # Recursively copies /tmp/tests to /home/jane$ cd /home/joe/Documents$ cp -r /tmp/tests .. # Recursively copies /tmp/tests to /home/joe
?
and *
$ lsa.txt b.txt c.txt data.dat test.txt$ ls *.txta.txt b.txt c.txt test.txt$ ls ?.txta.txt b.txt c.txt
[source]
and [target]
can be any paths, relative or absolute, even the special ones like .
and ..
$ cd /home/jane$ cp -r /tmp/tests . # Recursively copies /tmp/tests to /home/jane$ cd /home/joe/Documents$ cp -r /tmp/tests .. # Recursively copies /tmp/tests to /home/joe
?
and *
$ lsa.txt b.txt c.txt data.dat test.txt$ ls *.txta.txt b.txt c.txt test.txt$ ls ?.txta.txt b.txt c.txt
?.txt
is expanded into all matching objects in the directory (works with files and directories alike)[source]
and [target]
can be any paths, relative or absolute, even the special ones like .
and ..
$ cd /home/jane$ cp -r /tmp/tests . # Recursively copies /tmp/tests to /home/jane$ cd /home/joe/Documents$ cp -r /tmp/tests .. # Recursively copies /tmp/tests to /home/joe
?
and *
$ lsa.txt b.txt c.txt data.dat test.txt$ ls *.txta.txt b.txt c.txt test.txt$ ls ?.txta.txt b.txt c.txt
In the last example ?.txt
is expanded into all matching objects in the directory (works with files and directories alike)
In other words ls ?.txt
is equivalent to ls a.txt b.txt c.txt
There is no undo button here
There is no undo button here
Contrary to popular belief, Unix is user friendly. It just happens to be very selective about who it decides to make friends with.
-- unknown
These systems expect you to know what you are doing.
There is no undo button here
Contrary to popular belief, Unix is user friendly. It just happens to be very selective about who it decides to make friends with.
-- unknown
These systems expect you to know what you are doing.
Please use rm -r
sparingly and with care.
Keyboard shortcuts
↑, ←, Pg Up, k | Go to previous slide |
↓, →, Pg Dn, Space, j | Go to next slide |
Home | Go to first slide |
End | Go to last slide |
Number + Return | Go to specific slide |
b / m / f | Toggle blackout / mirrored / fullscreen mode |
c | Clone slideshow |
p | Toggle presenter mode |
t | Restart the presentation timer |
?, h | Toggle this help |
Esc | Back to slideshow |