ULI101 Week 2 Lecture Notes
ULI101 Week 2 Lecture Notes
File system is a system that allows to organize data and files in directories and subdirectories.
There is a single file structure (single root directory) in Unix/Linux, instead of having separate structures
for each drive.
cd /
Boot directory contains all of the files necessary to start the OS (boot loader swr, kernel images, etc.)
Dev is short for devices – this directory contains file names that represent our devices – they`re not the
devices themselves, nor device drives.
Home directory contains all the default directories for a user. Every user in the system should have a
directory in their home dir with his username. Ex: /home/vfogaca-tonioli
Every system has a superuser account (admin) – The name of the superuser account is called root
The user root also gets a home directory – it’s the only home dir not under “home”.
The tmp directory contains temporary files that are created during PC use. Some systems periodically
clean this directory.
The usr directory is the destination of where all the software is installed.
The var directory (variable data) is where system data is stored, such as our log files, access logs, security
logs, error logs, system logs, webserver logs, print queues, website by default would be under var.
The bin directory (binaries) – binaries means that it’s an executable file. It’s where the system stores the
commands. Not everything in bin is necessary a file (could also be a script).
The sbin directory is similar to bin, except they’re different commands in different places. These are
special commands for the system administrator. Typically only accessed by the user “root”.
The default behavior of the cd command (without any arguments) is to take you to ~
The first character on a file list specifies what kind of file it is:
Devices read and write streams of characters (keyboard) or blocks of characters (storage devices).
Read (R), write (W) and execute (X) permissions are listed on the 9 characters separated in 3 sets (LS
command)
When a file is created, by default its owned by somebody. (Third field ls –l tells whos the owner).
Ls –l fields: permissions / link / user / group / file size / timestamp / file name
. = this directory
ls –A can also be used like –a , the only difference is that . and .. don’t show up.
ls –l –a or ls –la
ls –d displays info about the dir itself instead of the files within it
mkdir is used to create a directory (accepts options and allows multiple directories to be created at the
same time)
There’s an option for mkdir called –p. Creates any missing parent directories.
Mkdir –p dir1/dir2
OR also
rmdir is used to remove an EMPTY directory. If there is a user, it also will not allow deletion.
mv is used to move something from a dir to another AND is also used to rename files/dirs.
If the last argument is not an existing directory, it RENAMES the origin directory.
Ex: if I try to move dir1 into dir2, but there’s already a directory called dir1 into dir2, it’s gonna override
the preexisting directory in dir2.
mv –i = prompt the user if it’s gonna do something destructive (by default it’s off).
cp file1 dir1 (existing dir) – copies file to dir1 and keeps its name
If the file already exists, it updates the timestamp (w/o modifying anything).
cat command is used to view the contents of a file. (Reads content and writes it on the screen)
more command is used to view and scroll through the content of a file.
less is a better paginator than more. You can use the arrow keys to scroll the contents.
find command allows searching for files by file name, size and file attributes throughout the file system.
find /
-name (filename)
man –k calendar (looks for keywords, in case you forgot a command’s name)
cal (1)