260 likes | 468 Views
Linux Introduction. What are the benefits of Linux?. A modern, very stable, multi-user, multitasking environment Unsurpassed computing power, portability, and flexibility Excellent networking capability Hundreds of specialized applications Freedom from viruses
E N D
What are the benefits of Linux? A modern, very stable, multi-user, multitasking environment Unsurpassed computing power, portability, and flexibility Excellent networking capability Hundreds of specialized applications Freedom from viruses A platform which will technically develop at a rapid pace Linux runs on many hardware platforms
File System: Filenames Linux is case-sensitive. Filenames under Linux can be up to 256 characters long Contain letters, numbers, ".“ (dots), "_" (underscores) and "-" (dashes) Not possible to have '/' (slash) as a part of the filename Not recommended to use special metacharacters: "*" (asterisk), "?" (question mark), " “ (space), "$" (dollar sign), "&" (ampersand), any brackets * = Matches any sequence of zero or more characters, except for "." (a dot) at the beginning of a filename. ? = Matches any single character. [abC1] = Matches a single character in the enumerated set. In this example the set contains: 'a', 'b', 'C', and '1'. [a-z] = Matches any lower-case letter. [A-F] = Matches any upper-case letter from A to F. [0-9] = Matches any single digit. [a-zA-Z0-9] = Matches any letter (lower or upper case) or any digit.
File System: Basic Directories The root "/" contains basic operating system and maintenance tools. /usr contains all commands, libraries, documentation, and major applications /var contains files that change: spool directories, log files, lock files, temporary files, and formatted manual pages. /home contains user files (users' own settings, customization files, documents, data, mail, caches, etc). /proc access to information about the system stored in the memory (they don't really exist on the disk)
File System: Basic Directories The parts of the root filesystem are: /bin--executables (binaries) needed during bootup that might be used by normal users /sbin--executables (system binaries) not intended for use by general users /etc--system-wide configuration files /root--the home directory of the system administrator (called super-user or root) /dev--hardware device files.
File System: Basic Directories Other parts of the root filesystem: /mnt--mount points for removable media (floppy, cdrom, zipdrive), partitions of other operating systems, network shares /lib--shared libraries for programs that reside on the root filesystem and kernel modules. /boot--files used by the bootstrap loader /tmp--temporary files.
File System: Basic Directories Other parts of the root filesystem: /usr/share --Data independent from computer architecture /usr/bin and /usr/sbin --similar to their equivalents on the root filesystem (/bin and /sbin), but not needed for basic bootup. Most commands will reside here. /usr/local/bin --perhaps smaller "user"-installed executables, plus symbolic links to the larger executables contained in separate subdirectories under /usr/local Command “mkdir” is used to create directories mkdir /mnt/cdrom
File System: Basic Directories • Swap space is an extension of the physical memory of the computer • Usually one is created at installation • Other swap partitions can be created and formatted • mkswap /dev/hda4 • Swap space can be enabled/disabled • swapon /dev/hda4 • swapoff /dev/hda4 • Temporary swap: Create a file with the size of your swap file: • dd if=/dev/zero of=/swapfile bs=1024 count=8192 • mkswap /swapfile 8192 • swapon /swapfile • swapoff /swapfile • rm /swapfil
Running Programs and Commands • Programs are executables binary files • To run a program: • It must be in your PATH or use its full path and name (Ex: /bin/date) • It must have Execute permissions set by owner • Programs in the current directory are run by: ./program_name • Most commands accept numerous "options". An option can be introduced with an "-" (dash). For example: ls –l –a OR ls -la
Running Programs and Commands • The PATH is the list of directories which are searched when you request the execution of a program • You can check your PATH using this command: echo $PATH Which returns something like: /opt/kde/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/yogin/bin • To set the PATH of a user, edit the profile file: /home/user_login_name/.bash_profile to add something like: PATH="$PATH:$HOME/bin:"." export PATH • Aliases can be created for long and hard to remember commands alias cdrom="mount -v /mnt/cdrom"
Users, passwords, file permissions • The “root” account is the super-user administrating account • normal users (non-root) can write to their home directory (created with their accounts) only (almost) /home/user_login_name • A user account can be created by "root" adduser joe passwd joe [type the password for the user joe] [retype the password for the user joe] • user changes his/her password passwd (current) UNIX password: pass_OLD New UNIX password: pass_NEW Retype New UNIX password: pass_NEW
Users, passwords, file permissions • Groups of users can be created • A user can be a member of one or more groups • Each file (or directory) belongs to an owner and to a group • The owner is typically the person who created (or copied) the file. • Permissions on file usage (r, w, x) are set by the owner for file users: • owner (u), group (g), other users (o), and all (a).
Users, passwords, file permissions • “ls –l” command lists the files and their permissions drwxr-xr-x 2 root root 21504 Apr 24 19:27 dev • Command “chmod” is used to change file permissions. • chmod a+r junk • chmod o-x junk • Instead of letters, one can also use numbers to specify the permissions • execute=1, write=2, read=4, 0= no permission • The total permission for a class of users is the sum of the three • chmod 770 junk • For directories: r=permission to list the filenames in the directory, w=permission to create or delete files in the directory, and x=permission to access the directory
Users, passwords, file permissions • Default permissions on new files are set by command “umask” • umask u=rw,g=,o= • umask 077 (numbers for permissions taken away not granted) • “suid” on executables so that all users users are given the "effective user id" of the file owner • chmod a+s /usr/bin/xmms • ls -l /usr/bin/xmms -rwsr-sr-x 1 root root 908k Feb 22 2000 /usr/bin/xmms
Shells • A shell is the program that interprets what you type on the command line and decides what to do with it • There are several shells available on the Linux system • bash ("Bourne Again“ shell) – default shell • sh (Bourne shell, standard on many UNIX systems) • csh (C shell, with a syntax akin to the "c“ programming language, available on most UNIX systems) • pdksh (public domain Korn shell) • tcsh (tiny C shell, often used on small systems) • sash (stand-alone shell, could be used when libraries are not available) • You can determine the shell you are running using: • echo $SHELL • To change the shell: • tcsh • bash • exit
Shells • To display shell prompt: • echo $PS1 • To set the prompt: • PS1="[\u@\h \W]\$ " • Fields of the prompt: • \u - username of the current user (= $LOGNAME), • \h - the name of the computer running the shell (hostname), • \H - entire hostname, • \W - the base of the name of the of the current working directory, • \w - the full name of the current working directory, • \$ - display "$" for normal users and "#" for the root, • \! - history number of the current command, • \# - number of the current command (as executed in the current shell), • \d - current date, • \t - current time (24-hr), • \T - current time (12-hr) - bash 2.0 only, • \@ - current time (AM/PM format) - bash 2.0 only, • \s - name of the shell, • \a - sound alarm (beep), • \j - number of jobs the user has, • \n - new line, • \\ - backslash, • \[ - begin a sequence of non-printable characters, • \] - end a sequence of non-printable characters, • \nnn - the ASCII character corresponding to the octal number nnn. • $(date) - output from the date command (or any other command for that matter)
Accessing Drives • “mount” command adds directories and files from a device to the Linux directory • mount the CDROM with a command (as root) • mount -t auto /dev/cdrom /mnt/cdrom • /dev/cdrom should exist first • If this works, the contents of the CD appears in the directory /mnt/cdrom • To unmounta mounted CD, exit the directory /mnt/cdrom and type as root: • umount /mnt/cdrom
Accessing Drives • A short listing of possible drives could include: • hda -- the master drive on the first IDE interface (that's always the first hard drive) • hdb -- the slave drive on the first IDE interface (you must have at least two hard drives for that) • hdc -- the master drive on the second IDE interface (if you have two IDE interfaces on your computer, most newer computers do) • hdd -- the slave drive on the second IDE interface (if you have one) • sda -- the first SCSI drive • sdb -- the second scsi drive ("sdc" is the third scsi drive, etc. There can be many scsi drive on a system). • USB and parallel devices are handled SCSI devices
Accessing Drives • Mounting DOS/Windows FAT partition • mount -t vfat /dev/hda1 /mnt/dosdrive • To mount so that all the users can read and write • mount -t vfat -o user,rw,exec,umask=000 /dev/hda1 /mnt/dosdrive • Mounting from Network File System (NFS) • mount -t nfs mars:/home /mnt/mars_home • For automount, the mount commands are added to the the file /etc/fstab
Working with X-windows • GUI is provided through X-servers (XF86) • Two major GUI desktop packages available as options on installations: KDE and GNOME • KDE programs can be run under GNOME and vice versa, • KDE is older, more solid, more power requiring • GNOME is lighter but less stable • Default display is number 0
Working with X-windows • Switching between text and graphics modes • <Ctrl><Alt><F1> to <Ctrl><Alt><F6> for a total of 6 text consoles • <Ctrl><Alt><F7> to <Ctrl><Alt><F11> for a total of 5 graphics consoles • To start the X-server • startx & OR • init 5 • To start KDE or GNOME • Startkde • gnome-session
Some Essential Keyboard Shortcuts • <Tab> Autocomplete the command if there is only one option, or else show all the available options • <ArrowUp> Scroll back and edit the command history • <Shift><PgUp> Scroll terminal output up • <Ctrl><Alt><Esc> Kill the window to be clicked with mouse pointer • <Ctrl><Alt><BkSpc> Kill the current X-windows server • <Ctrl><Alt><Del> Shut down the system and reboot. • <Ctrl>c Kill the current program
Getting Help on Commands • any_command --help |more Display a brief help on a command (works with most commands). • man topicDisplay the contents of the system manual pages (help) on the topic. Press "q" to quit the viewer. • info topicDisplay the contents of the info on a particular command. • apropos topicGive the list of the commands that have something to do with a topic. • whatis topicGive a short list of commands matching a topic. Searches keywords only. • help commandDisplay brief info on a bash (shell) built-in command
Some Basic Commands • pwd Print working directory, i.e., display the name of my current directory on the screen • whoami Print my login name • date Print the operating system current date, time and timezone. • date 123123572000 Change the date and time to 2000-12-31 23:57 • time Determine the amount of time that it takes for a process to complete (eg., time ls) • history | more Show the last (1000 or so) commands executed from the command line on the current account. • df –h (=disk free) Print disk info about all the filesystems (in human-readable form). • du / -bh | more (=disk usage) Print detailed disk usage for each subdirectory starting at the "/" (root) directory (in human legible form)
Some Basic Commands • ~ is the home directory of the user • ls OR dir List the contents of the current directory. • ls –al List the content of the current directory, all files (also those starting with a dot) with all details • cd directory_nameChange directory. • cd - will take you to your previous directory • cd .. will take me one directory up • cp source destinationCopy files. • cp /home/stan/existing_file_name . Copy a file to the current working directory. • -R option (stands for "recursive") to copy the contents of whole directory trees, • mv source destinationMove or rename files or directories • ln source destinationCreate a hard link called destination to the file called source • ln -s source destinationCreate a symbolic (soft) link called "destination" to the file called "source"
Some Basic Commands • rm filesRemove (delete) files • -f (=force) Delete without confirmation • rm -r files(recursive remove) Remove files, directories, and their subdirectories. • mkdir directory_nameMake a new directory. • cat filenameView the content of a text file called "filename“ • cat filename | more one page a time. • cat filename | less OR less filename Scroll a content of a text file. Press q when done.