1 / 47

UNIX/LINUX OPERATING SYSTEM

UNIX/LINUX OPERATING SYSTEM. Linux Commands. UNIX/LINUX Commands. A command is a program which interacts with the kernel to provide the environment and perform the functions called for by the user.

schrock
Download Presentation

UNIX/LINUX OPERATING SYSTEM

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. UNIX/LINUX OPERATING SYSTEM

  2. Linux Commands UNIX/LINUX Commands • A command is a program which interacts with the kernel to provide the environment and perform the functions called for by the user. • A command can be: a built-in shell command; an executable shell file, known as a shell script; or a source compiled, object code file. • The shell is a command line interpreter. The user interacts with the kernel through the shell. You can write ASCII (text) scripts to be acted upon by a shell. • It reads the terminal input and translates the commands into actions taken by the system. The shell is analogous to command.com in DOS.

  3. Linux Commands UNIX Shell • The original shell was the Bourne shell, sh. • Every Unix platform will either have the Bourne shell, or a Bourne compatible shell available. • The default prompt for the Bourne shell is $ (or #, for the root user). • Another popular shell is C Shell. The default prompt for the C shell is %.

  4. Linux Commands Shell Programming • You can write shell programs by creating scripts containing a series of shell commands. • The first line of the script should start with #! which indicates to the kernel that the script is directly executable. • You immediately follow this with the name of the shell, or program (spaces are allowed), to execute, using the full path name. So to set up a Bourne shell script the first line would be: #! /bin/sh • The first line is followed by commands #!/bin/bash cd /tmp mkdir t • You also need to specify that the script is executable by setting the proper bits on the file with chmod, e.g.: $ chmod +x shell_script

  5. Linux Commands LINUX COMMANDS • File Management and Viewing • Help, Job and Process Management • Network Management • System Management • User Management • Miscellaneous

  6. Linux Commands Command Structure • Command <Options> <Arguments> • Multiple commands separated by ; can be executed one after the other

  7. Linux Commands Help Facilities for Commands • To understand the working of the command and possible options use (man command) • Using the GNU Info System (info, info command) • Many tools have a long−style option, `−−help', that outputs usage information about the tool, including the options and arguments the tool takes. Ex: whoami --help

  8. Linux Commands Pipes • An important early development in Unix was the invention of "pipes," a way to pass the output of one tool to the input of another. eg. $ who | wc −l By combining these two tools, giving the wc command the output of who, you can build a new command to list the number of users currently on the system

  9. QUESTIONS?

  10. Introduction to Linux Listing the Content of a Directory • ls is used to list the contents of a directory. • If the command ls is written with parameter –l then the command lists contents of the working directory with details. Example: $ ls –l

  11. Introduction to Linux Moving in Directories • cd try_it Changes the directory to try_it • pwd Prints present working directory (e.g. /home/smith/try_it) • cd .. Move to superior directory pwd : Prints /home/smith • cd /home The absolute path pwd : Prints /home • cd The system is returned to the user home directory pwd : Print /home/smith

  12. Introduction to Linux Make Directory • The command mkdir test makes new directory test (the path is given relative) as a subdirectory of the current directory.

  13. Introduction to Linux Remove Directory • The command rmdir your_dir removes directory your_dir if it is empty. • The command rm –rf is used to delete a non empty directory

  14. Introduction to Linux Copy File • The command cp file_1 file_2 copies file_1 to file_2. The both files must be in the same working directory. If they are in various directories, the path must be given.

  15. Introduction to Linux Rename and/or Move the File • The command mv file_1 file_2 moves file_1 to file_2 • The both files must be in the same working directory. • If they are in different directories, the path must be given. • The file_1 is removed from the disk.

  16. Introduction to Linux Remove File • The command rm file_a removes the file_a from the system • If you use wildcard. For example rm h*c you will remove all files beginning with h and ending with c which are in working directory. • If you write rm * you will erase all files from your working directory.

  17. Introduction to Linux Access Permission of File/Directory • The ownership of the file or directory can be changed using the command chown <owner> <file/directory name> • The group of the file or directory can be changed using the command chgrp <group> <file/directory name> • The permissions of the file can be changed using chmod command chmod -R ### <filename or directory> • -R is optional and when used with directories will traverse all the sub-directories of the target directory changing ALL the permissions to ###.

  18. Introduction to Linux Access Permission of File/Directory • The #'s can be: 0 = Nothing1 = Execute2 = Write3 = Execute & Write  (2 + 1)4 = Read5 = Execute & Read (4 + 1)6 = Read & Write (4 + 2)7 = Execute & Read & Write (4 + 2 + 1)

  19. QUESTIONS?

  20. Linux Commands Linux File Management and Viewing • find Find files (find <start directory> -name <file name> -print) Ex: find /home –name readme -print (Search for readme starting at home and output full path.)“/home" = Search starting at the home directory and proceed through all its subdirectories "-name readme" = Search for a file named readme "-print" = Output the full path to that file • locate File locating program that uses the slocate database. Ex: locate –u to create the database, locate <file/directory> to find file/directory

  21. Linux Commands Linux File Management and Viewing File viewing and editing • vi Editor with a command mode and text mode. Starts in command mode. • gedit GUI Text Editor • tail Look at the last 10 lines of a file. Ex: tail -100 <filename> (looks at last 100 lines) • head Look at the first 10 lines of a file. (head <filename>)

  22. Linux Commands Linux File Management and Viewing • cat View a file Ex: cat filename • grep List all files with the specified expression. (grep pattern <filename/directorypath>)Ex: ls –l |grep sidbi : List all lines with a sidbi in them. Ex: grep " R " : Search for R with a space on each side • sleep Delay for a specified amount of time. • sort Sort a file alphabetically. • uniq Remove duplicate lines from a sorted file. • wc Count characters, words and lines in a file. (wc –c/w/l <filename>).

  23. Linux Commands Network Management Commands • ping Send ICMP ECHO_REQUEST packets to network hosts. (ping <remote-host-name/ip>) • ssh Secure Login (ssh <remote system name/ip>) • telnet User interface to the TELNET protocol, setting up a remote console session. (telnet <remote system name/ip>) • tcpdump Dump traffic on a network. Prints out headers of packets that match the boolean expression. (tcpdump eth0) • traceroute Print the route that packets take to the specified network host. (traceroute <remote system name/ip>)

  24. Linux Commands System Management Commands • shutdown If your system has many users, use the command shutdown -h +time ‘<message>`, where time is the time in minutes until the system is halted, and message is a short explanation of why the system is shutting down. Ex: # shutdown -h +10 'We will install a new disk. System should be back on-line in three hours’. • passwd Set a user's pass word. (passwd, passwd <username>)

  25. Linux Commands System Management Commands • su Single user login. (su -) • who Display the users logged in. • whoami Print effective user id.

  26. Linux Commands Linux Job & Process Management Linux Process Management • ps Get the status of one or more processes. PPID-parent process ID ; PID-process ID Eg: ps ax |more to see all processes including daemons Eg : ps –ef | grep <process> • top The top program provides a dynamic real-time view of a running system. It can display system summary information as well as a list of tasks currently being managed by the Linux kernel

  27. Linux Commands Linux Job & Process Management Linux Process Management • kill Ex: "kill 34" - Effect: Kill or stop the process with the process ID number 34. • killall Kill processes by name. • pid Find the process ID of a running program

  28. QUESTIONS?

  29. Linux System Administration SYS ADMIN TASKS • Setting the Run Level • System Services • User Management • Network Settings • Scheduling Jobs • Backup and Restore • Adding and Removing software/packages • Monitoring the system (general, logs)

  30. Linux System Administration Init Runlevels • The following runlevels are defined in Linux: • 0 - halt (Do NOT set initdefault to this) • 1 - Single user mode • 2 - Multiuser, without Network (The same as 3, if • you do not have networking) • 3 – Text Mode • 4 - unused • 5 – Graphical Mode • 6 - reboot (Do NOT set initdefault to this)

  31. Desktop Configuration Init Runlevels • The default runlevel for a system to boot to is configured in /etc/inittab. id:5:initdefault: • In GUI: Applications  System Settings  Server Settings Services • Generally, Linux operates in runlevel 3 or 5.

  32. Linux System Administration Linux Services There are 113 deamons, each for a service or application. Some examples are: • httpd : Apache Web server • mysqld : MySQL server • named : DNS server • network : Networking • nfs : Network File Share • ntpd : NTP (Network Time Protocol) server

  33. Linux System Administration Linux Services • Start/Stop boot time services in /etc/rc.d/rc3.d or /etc/rc.d/rc5.d • All services startup scripts which start with S will start at boot time and all startup scripts which start with K will not start at boot time. The number after S or K is the priority. K95kudzu K96pcmcia S56xinetd S60vsftpd • Use service <service name> start/stop/restart to start, stop or restart a service from command line

  34. Linux System Administration Creating a new User Account • Add an entry in /etc/passwd and /etc/shadow file (use next uid and suitable gid). You will have to create the user directory and assign a password to the user • Use useradd or adduser command to create a new user (useradd –g <group> -d <home directory> -c <comment> -s <shell> login-name) and groupadd to create a new group (groupadd group-name). You will have to assign a password (passwd login-name) • In GUI: Applications  System Settings  Users and Groups

  35. Linux System Administration /etc/passwd and /etc/shadow File • /etc/passwd Holds user account info Included fields are: • Login name • User Id (uid) • Group Id (gid) • General Comment about the user • Home Directory • Shell • /etc/shadow Contains the encrypted password information for users' accounts and optionally the password aging information.

  36. Linux System Administration Removing a User Account • userdel –r <username> • Remove login id from /etc/passwd & /etc/shadow file and delete home directory • Use GUI to Delete the user

  37. QUESTIONS?

  38. Linux System Administration Linux Network Configuration • /etc/resolv.conf Tells the kernel which name server should be queried when a program asks to "resolve" an IP Address. nameserver 172.31.1.1 search cc.iitk.ac.in iitk.ac.in • /etc/sysconfig/network Indicates networking is enabled (NETWORKING=yes) and provides information on hostname, gateway and nis domain. NETWORKING=yes HOSTNAME=webhome.cc.iitk.ac.in GATEWAY=172.31.1.250

  39. Linux System Administration Linux Network Configuration • /etc/sysconfig/network-scripts/ifcfg-eth0 Network configurations like boot protocol (static/dhcp), ip address, netmask, network address, broadcast address etc. DEVICE=eth0 ONBOOT=yes BOOTPROTO=static IPADDR=172.31.1.40 NETMASK=255.255.0.0 BROADCAST=172.31.255.255 NETWORK=172.31.0.0 GATEWAY=172.31.1.250

  40. Linux System Administration Scheduling Jobs: Cron • Cron is a program that enables you to execute a command, or a script with a sequence of commands, at a specified date, time or at set intervals. • Add the job script in /etc/cron.hourly or /etc/cron.daily or /etc/cron.weekly or /etc/cron.monthly to schedule a job

  41. Linux System Administration Backup & Restore • Backup the user area or configuration file • Use tar to take backup on a different disk or tape • Backup can be scheduled using cron • Backup: tar –zcvf <tar filename> <Directory Tree to be backedup> • Restore: tar –zxvf <tar filename> <file to be recovered> • Backup should be occasionally checked by restoring it • Backup Policy: Full Backup every weekly/fortnightly and incremental backup every day

  42. Linux System Administration Adding & Removing Software • Download a binary • Download the source code and compile on the system (download, untar, configure, make, make install, make uninstall) • Use RPM - Redhat Package Manager and install rpms • www.rpmseek.com & www.rpmfind.net can be used to search and download rpms (i386 Binary RPMs or SRC RPMs) • For Binary rpms: rpm [options] rpm-file (rpm –qa, rpm –ivh, rpm –Uvh, rpm -e) Where -q= query, -a= all, -i=install, -v=verbrose, -U= upgrade, -h= hash, -e= erase • For Source rpms: rpmbuild –rebuild rpm-source-file Compiled binary rpms will be available at /usr/src/redhat/RPMS/i386 which can be installed

  43. Linux System Administration Monitoring the System • Monitor Disk Usage (df) • Monitor CPU and Memory utilization (top) • Monitor process/services (ps, pgrep) • Monitor logs (/var/log/messages) • GUI Tool (Applications System Tools System Performance)

  44. QUESTIONS?

More Related