Documente Academic
Documente Profesional
Documente Cultură
Directories
/
etc dev home boot
/ /etc /boot /dev /usr /home /var
bin
usr
lib
- first of mount point in linux - keep linux default configuration - keep important linux booting files - keep all device files - keep all user binary and X library - keep user home directory - keeping mail, log file and printer spooling
Directories
Directory Used to organize other files into a logical tree structure Absolute pathname Pathname from the root directory to a certain file or directory Root The top level directory
Directories
~ metacharacter Can be used to refer to the current users home directory Can be used to specify another users home directory by appending a username at the end of the ~ metacharacter Relative pathname Pathname of a target directory relative to your current directory in the tree
Shells
Shell accepts commands, interprets them and pass them to kernel.
bash Most commonly used shell. csh Syntax is very familiar to the C- proramming language ksh korn shell tcsh
Linux Basics
Navigation and searching
Navigation
ls Lists the entries of a directory ls a lists all, including system files. mkdir cd PATH
cd takes the user to its home
Navigation
mv file1 file2 moves files or rename file rm file removes a file rmdir dir removes a directory cat file prints the contents whoami man k help or --help
File types
Text files Store information in a readable text format Binary data files Store information associated with executable programs Executable program files Directory files
File types
Linked files Associated with another file Special device files Represent system devices Named pipes Identify channel that passes information between processes Socket files Allow a process on another computer to write to a local file
tail command
By default, displays the last 10 lines (including blank lines) of a text file to the terminal screen Can also take a numeric option specifying a different number of lines to display
The more and less commands can also be used in conjunction with the output of other commands
If output is too large to fit on terminal screen, use | metacharacter, e.g. ls -l | more
Searching files
updatedb locate file find name file* find name * size +500k grep string file ls grep|new grep b.*g file
Searching files
which command Command used to locate files that exist within directories listed in the PATH variable PATH variable Lists directories on system where executable files are located Allows executable files to be run without specifying absolute or relative path
Manipulation
vi file opens a file in current directory for editing. commands:
:q :q! :w :wq / -searching string Select some text to copy it, and right click pastes it.
Manipulation
emacs Emacs is more than "just an editor" -- it provides a fully integrated user environment offering the sort of facilities outlined below.
Issue shell comands Read and send mail Read news Access the internet Write and test programs Maintain a calendar Play a game!
nano gedit
Character devices
Transfer data to and from the system one data bit at a time
Block devices
Transfer to and from the system in chunks of many bits by caching the information in RAM Represented by block device files Fast data transfer
/dev/hdb1
/dev/hdc1 /dev/hdd1 /dev/sda1 /dev/cdrom
First primary partition on the second IDE hard disk drive (primary slave)
First primary partition on the third IDE hard disk drive (secondary master) First primary partition on the fourth IDE hard disk drive (secondary slave) First primary partition on the first SCSI hard disk drive Default CD-ROM/DVD-ROM drive
Block
Block Block Block Block
Minor number
Used by the kernel to identify which specific hardware device, within a given category, to use a driver to communicate with
mknod command
Can be used to re-create a corrupted device file Must know file type, major, and minor numbers
Filesystem Types
Filesystem Description bfs Boot File Systema small bootable filesystem used to hold the files necessary for system startup; it is commonly used on UNIX systems Compact disc filesystemused to view all tracks and data on a CD-ROM as normal files Second extended filesystemcurrently the most common filesystem used on Linux, it supports Access Control Lists (individual user permissions). It retains its name from being the new version of the original extended filesystem, based on the Minix filesystem Third extended filesystem; a variation on ext2 that allows for journaling and thus has a faster startup and recovery time
cdfs ext2
ext3
Filesystem Types
Filesystem hfs Description Hierarchical File Systema filesystem native to Apple Macintosh computers
hpfs
iso9660
High Performance File Systeman IBM-proprietary OS/2 filesystem that provides long file name support and is optimized to manipulate data on large disk volumes The CD-ROM filesystemoriginated from the International Standards Organization recommendation 9660 and used to access data stored on CD-ROMs The MINIX filesystemfilesystem used by Linus Torvalds in the early days of Linux development
The DOS FAT filesystem The DOS FAT filesystem with long file name support
Filesystem Types
Filesystem ntfs Description New Technology File Systema Microsoft-proprietary filesystem developed for its NT4 and Windows 2000 operating systems, currently available as a read-only filesystem under Linux The REISERFS filesystema journaling filesystem similar to ext3 more suited for use with databases The Universal Disk Format filesystemA filesystem used by software systems that write to a CD-R, CD-RW or DVD
reiserfs udf
vxfs
The Veritas filesystema journaling filesystem that offers large file support, supports Access Control Lists (individual user permissions), and is commonly used by major versions of UNIX
Mounting
Mounting
Making a device accessible to users via the logical directory tree Term originated in the 1960s, when information was stored on large tape reels that had to be mounted on computers to make the data available
Mount point
Directory in a file structure to which a device is attached
Any existing directory can be a mount point
Mounting
/ mnt root data etc home
floppy
cdrom
mary
bob
sue
Mounting
/ mnt root data etc home
mary
bob
sue
/mnt
Mounting
/ mnt root data etc home
mary cdrom
bob
sue
floppy
/mnt/floppy
Mounting
When the Linux filesystem is first turned on, a filesystem present on the hard drive is mounted to the / directory Root filesystem
Filesystem that contains files that start up the operating system Should have enough free space to prevent errors and slow performance
Mounting
mount command
Used to mount devices to mount point directories With no options or arguments, lists currently mounted filesystems
umount command
Used to unmount devices from mount point directories
To mount or unmount floppies, must ensure that no user is currently using the mount point directory
Most (almost all) floppy disks today come preformatted with the DOS FAT filesystem
Will work just fine for Linux when mounted correctly (Work on Macs as well)
Used to create an ext2 filesystem Used to create an ext3 filesystem (j = journaling) Used to create a CD-ROM filesystem Used to create a REISERFS filesystem
fuser -u <directory>
Reduces the chance the filesystem corruption will render a system unusable Speeds up access to stored data by keeping filesystems as small as possible
Sector
Smallest unit of data storage on a hard disk
Block
Unit of data commonly used by filesystem commands
Track Sector
Block
/dev/hda2
/dev/hda3
/dev/sda2
/dev/sda3
/dev/hda4
/dev/hda5 /dev/hda6 /dev/hda7 /dev/hda8 /dev/hda9 /dev/hdan
/dev/sda4
/dev/sda5 /dev/sda6 /dev/sda7 /dev/sda8 /dev/sda9 /dev/sdan
Common hard disk partition device files for /dev/hda and /dev/sda
hda2
hda5
logical
MBR
(MBB)
hda5
logical
hda7
logical
hda6
logical
MBR
(MBB)
Edit /etc/fstab file to allow system to mount new filesystems automatically at boot time
Monitoring Filesystems
Check mounted filesystems periodically
Errors Disk Space usage Inode usage
Disk Usage
Using more filesystems typically results in less hard disk space per filesystem
Errors when filesystems fill up with data
e.g., free space on / filesystem falls below 10%
Disk Usage
du (directory usage) command
View size of a directory and contents in Kilobytes s option: Summarizes output
dumpe2fs command
View total number of inodes and free inodes for ext2 or ext3 filesystem Use h option
Filesystem corruption
Errors in a filesystem structure that prevent the retrieval of stored data Commonly occurs due to improper system shutdown
Syncing
Process of writing data stored in RAM to the HDD
Bad blocks
Unusable areas of a disk Cannot hold a magnetic charge
e2fsck command
Check ext2 and ext3 filesystems
reiserfsck
Check reiserfs filesystems
Soft limits
Limit imposed that can be exceeded for a certain period of time
Hard limit
Limit imposed that cannot be exceeded
edquota command
Edit user quotas
repquota command
Report user quotas
quota command
Allows regular users to view quotas and current usage