Introduction To Linux - Interdisciplinary

Transcription

Introduction to LinuxAlexander B. PachecoUser Services ConsultantLSU HPC & LONIsys-help@loni.orgHPC Training Spring 2013Louisiana State UniversityBaton RougeFebrurary 6, 2013Introduction to LinuxHPC Training: Spring 2013February 6, 20131 / 80

Outline1What is Linux?2Variables3Basic Commands4Redirection5File Permissions6Process Management7Editors8Basic Shell Scripting9What is a scripting Language?10Writing Scripts11Arithmetic Operations12HPC HelpIntroduction to LinuxHPC Training: Spring 2013February 6, 20132 / 80

History IUnix was conceived and implemented in 1969 at AT&T Bell labs by KenThompson, Dennis Ritchie, Douglas McIlroy, and Joe Ossanna.First released in 1971 and was written in assembler.In 1973, Unix was re-written in the programming language C by DennisRitchie (with exceptions to the kernel and I/O).The availability of an operating system written in a high-level languageallowed easier portability to different computer platforms.The GNU Project, started in 1983 by Richard Stallman, had the goal ofcreating a “complete Unix-compatible software system” composedentirely of free software.386BSD released in 1992 and written by Berkeley alumni Lynne Jolitzand William Jolitz. FreeBSD, NetBSD, OpenBSD and NextStep (MacOSX) descended from thisAndrew S. Tanenbaum wrote and released MINIX, an inexpensiveminimal Unix-like operating system, designed for education in computerscienceIntroduction to LinuxHPC Training: Spring 2013February 6, 20133 / 80

History IIFrustated with licensing issues with MINIX, Linus Torvalds, a student atUniversity of Helsinki began working on his own operating system whicheventually became the "Linux Kernel"Linus released his kernel for anyone to download and help furtherdevelopment.Linus’s message to comp.os.minix on Aug 26, 1991Hello everybody out there using minix I’m doing a (free) operating system (just a hobby, won’t be big and professional like gnu) for 386(486) ATclones. This has been brewing since april, and is starting to get ready. I’d like any feedback on thingspeople like/dislike in minix, as my OS resembles it somewhat (same physical layout of the file-system (dueto practical reasons) among other things).I’ve currently ported bash(1.08) and gcc(1.40), and things seem to work. This implies that I’ll get somethingpractical within a few months, and I’d like to know what features most people would want. Any suggestionsare welcome, but I won’t promise I’ll implement them :-)Linus (email address)PS. Yes - it’s free of any minix code, and it has a multi-threaded fs. It is NOT protable (uses 386 taskswitching etc), and it probably never will support anything other than AT-harddisks, as that’s all I have :-(.https://groups.google.com/forum/?fromgroups uction to LinuxHPC Training: Spring 2013February 6, 20134 / 80

History IIILinux is only the kernel, an Operating System also requires applicationsthat users can use.combined with free software available from the GNU project gave birthto a new Operating System known as "GNU/Linux"GNU/Linux or simply Linux is released under the GNU Public License:Free to use, modify and distribute provided you distribute under theGNU Public License.Introduction to LinuxHPC Training: Spring 2013February 6, 20135 / 80

History IVhttp://en.wikipedia.org/wiki/LinuxIntroduction to LinuxHPC Training: Spring 2013February 6, 20136 / 80

What is Linux?Linux is an operating system that evolved from a kernel created byLinus Torvalds when he was a student at the University of Helsinki.It’s meant to be used as an alternative to other operating systems,Windows, Mac OS, MS-DOS, Solaris and others.Linux is the most popular OS used in a SupercomputerOS FamilyCountShare %LinuxUnixMixedWindowsBSD Based4692073193.841.40.60.2If you are using a Supercomputer for your research, there is a 98%probability that it will be based on a *nix ion to LinuxHPC Training: Spring 2013February 6, 20137 / 80

What is Linux?Many software vendors release their own packaged Linux OS (kernel,applications) known as distributionLinux distribution Linux kernel GNU system utilities and libraries Installation scripts Management utilities etc.1 Debian, Ubuntu, Mint2 Red Hat, Fedora, CentOS3 Slackware, openSUSE, SLES, SLED4 GentooApplication packages on Linux can be installed from source or fromcustomized packages1 deb: Debian based distros e.g. Debian, Ubuntu, Mint2 rpm: Red Hat based distros, Slackware based distros.Linux distributions offer a variety of desktop environment.123456K Desktop Environment (KDE)GNOMEXfceLightweight X11 Desktop Environment (LXDE)CinnamonMATEIntroduction to LinuxHPC Training: Spring 2013February 6, 20138 / 80

openSUSE KDE DesktopIntroduction to LinuxHPC Training: Spring 2013February 6, 20139 / 80

CentOS GNOME DesktopIntroduction to LinuxHPC Training: Spring 2013February 6, 201310 / 80

LXDE DesktopIntroduction to LinuxHPC Training: Spring 2013February 6, 201311 / 80

Debian MATE DesktopIntroduction to LinuxHPC Training: Spring 2013February 6, 201312 / 80

Linux Mint Cinnamon DesktopIntroduction to LinuxHPC Training: Spring 2013February 6, 201313 / 80

What is Linux?Linux distributions are tailored to different requirements such as123456ServerDesktopWorkstationRoutersEmbedded devicesMobile devices (Android is a Linux-based OS)Almost any software that you use on windows has a roughly equivalentsoftware on Linux, most often multiple equivalent softwaree.g. Microsoft Office equivalents are OpenOffice.org, LibreOffice, KOfficeFor complete list, visit http://wiki.linuxquestions.org/wiki/Linux software equivalent to Windows softwareLinux offers you freedom, to choose your desktop environment,software.Introduction to LinuxHPC Training: Spring 2013February 6, 201314 / 80

Popularity of Linux DistributionsDistroWatch providesnews, popularity rankings,and other generalinformation about:1various Linuxdistributions,2free software/opensource Unix-likeoperating systems suchas OpenSolaris, MINIXand BSD.DistroWatch is NOT anindication of market-shareor quality nor is it anindication of how manyusers but it is clearly anindication of what users arelooking roduction to LinuxHPC Training: Spring 2013February 6, 201315 / 80

Linux Components ILinux is made up of two (three) KernelIntroduction to LinuxHPC Training: Spring 2013February 6, 201316 / 80

Linux Components IIWhat is a kernelThe kernel is the main component of most computer operating systemsIt is a bridge between applications and the actual data processing doneat the hardware level.The kernel’s responsibilities include managing the system’s resources(the communication between hardware and software components).provides the lowest-level abstraction layer for the resources (especiallyprocessors and I/O devices) that application software must control toperform its function.It typically makes these facilities available to application processesthrough inter-process communication mechanisms and system calls.Introduction to LinuxHPC Training: Spring 2013February 6, 201317 / 80

Linux Components IIIWhat is a SHELLThe command line interface is the primary interface to Linux/Unixoperating systems.Shells are how command-line interfaces are implemented in Linux/Unix.Each shell has varying capabilities and features and the user shouldchoose the shell that best suits their needs.The shell is simply an application running on top of the kernel andprovides a powerful interface to the system.Introduction to LinuxHPC Training: Spring 2013February 6, 201318 / 80

Types of Shellsh : Bourne Shell Developed by Stephen Bourne at AT&T Bell Labscsh : C Shell Developed by Bill Joy at University of California, Berkeleyksh : Korn Shell Developed by David Korn at AT&T Bell Labs backward-compatible with the Bourne shell and includes many features ofthe C shellbash : Bourne Again Shell Developed by Brian Fox for the GNU Project as a free softwarereplacement for the Bourne shell (sh). Default Shell on Linux and Mac OSX The name is also descriptive of what it did, bashing together the featuresof sh, csh and kshtcsh : TENEX C Shell Developed by Ken Greer at Carnegie Mellon University It is essentially the C shell with programmable command line completion,command-line editing, and a few other features.Introduction to LinuxHPC Training: Spring 2013February 6, 201319 / 80

Shell ComparisonSoftwareshcshtcshkshbashProgramming LanguageShell VariablesCommand aliasCommand historyFilename completionCommand line editingJob control33777773333M7333333333333MM333333333 : Yes7 : NoM : Yes, not set by defaultRef ell.htmlIntroduction to LinuxHPC Training: Spring 2013February 6, 201320 / 80

Files and ProcessesEverything in Linux/UNIX is either a file or a processA File is a collection of data, created by users using text editors, runningcompilers, etc.Examples of Files:1234document such as collection of ascii text as in report, essay, etc.program written in some high level programming languageinstructions comprehensible to machine but not a casual usersuch as executable, binary filedirectory containing information about its contents such assubdirectories or other filesA process is an executing program identified by a unique processidentifier or PID.Introduction to LinuxHPC Training: Spring 2013February 6, 201321 / 80

Directory StructureAll files are grouped in a directory structureThe file-system is arranged in a hierarchial structure, like an inverted tree.The top of the hierarchy is traditionally called root (written as a slash / )/binbootdevetchomemntlibtmpusrvarworkuser1 user2 · · duction to LinuxHPC Training: Spring 2013···IntelamberGNUpython······February 6, 201322 / 80

Important Directories/bin: contains files that are essential for system operation,available for use by all users./lib,/lib64: contains libraries that are essential for system operation,available for use by all users./var: used to store files which change frequently (system level notuser level)/etc: contains various system configurations/dev: contains various devices such as hard disk, CD-ROM driveetc/sbin: same as bin but only accessible by root/tmp: temporary file storage/boot: contains bootable kernel and bootloader/usr: contains user documentations, binaries, libraries etc/home: contains home directories of all users. This is the directorywhere you are at when you login to a Linux/UNIX system.Introduction to LinuxHPC Training: Spring 2013February 6, 201323 / 80

UNIX like OS’s are designed for multi user environments i.e. multipleusers can exist on the system.Special user called root is the administrator and has access to all filesin the system.In *nix, users are organized into groups.Each user is in alteast one group.F On LONI systems, you are in one of the following groups: lsuusers,latechusers, unousers, ullusers, sususers,tulaneusers, loni or xavierusersDue to software licensing, you cannot be in more than one of the abovegroups.Group membership makes it easier to share files with members of yourgroup or in the case of LONI systems, with researchers at youruniversity.Type groupsto find your group membership.All files are case sensitive,F myfile.txt, Myfile.txt and myfile.TXT are three different files and can existin the same directory simultaneously.Introduction to LinuxHPC Training: Spring 2013February 6, 201324 / 80

Relative & Absolute PathPath means a position in the directory tree.You can use either the relative path or absolute pathIn relative path expression. (one dot or period) is the current working directory. (two dots or periods) is one directory upYou can combine . and . to navigate the file system hierarchy.the path is not defined uniquely and does depend on the currentpath././tmp is unique only if your current working directory is yourhome directory.In absolute path expressionthe path is defined uniquely and does not depend on the currentpath/tmp is unique since /tmp is the abolute pathIntroduction to LinuxHPC Training: Spring 2013February 6, 201325 / 80

Variables I*nix also permits the use of variables, similar to any programminglanguage such as C, C , Fortran etcA variable is a named object that contains data used by one or moreapplications.There are two types of variables, Environment and User Defined andcan contain a number, character or a string of characters.Environment Variables provides a simple way to share configurationsettings between multiple applications and processes in Linux.By Convention, enviromental variables are often named using alluppercase letterse.g. PATH, LD LIBRARY PATH, LD INCLUDE PATH, TEXINPUTS,etcTo reference a variable (environment or user defined) prepend to thename of the variablee.g. PATH, LD LIBRARY PATHIntroduction to LinuxHPC Training: Spring 2013February 6, 201326 / 80

Variables IIThe command printenv list the current environmental variables.F Type printenv on your command prompt to list allenvironment variables in your current session.The command env is used to either print a list of environment variablesor run another utility in an altered environment without having to modifythe currently existing environment.F Type env SHELL /bin/tcsh xterm to start an xtermsession in tcsh To execute the above command successfully, you needto be in GUI mode on the virtual OS or logged into aremote systems with X-Forwarding enabled.Introduction to LinuxHPC Training: Spring 2013February 6, 201327 / 80

Variables IIIPATH: A list of directory paths.HOME: indicate where a user’s home directory is located in the filesystem.PWD: contains path to current working directory.OLDPWD: contains path to previous working directory.TERM: specifies the type of computer terminal or terminal emulatorbeing usedSHELL: contains name of the running, interactive shell.PS1: default command promptPS2: secondary command promptLD LIBRARY PATH: colon-separated set of directories where librariesshould be searched for firstHOSTNAME: The systems host nameUSER: Current logged in user’s nameDISPLAY: Network name of the X11 display to connect to, if available.Introduction to LinuxHPC Training: Spring 2013February 6, 201328 / 80

Variables IVYou can edit the environment variables.Command to do this depends on the shellF To add your bin directory to the PATH variablesh/ksh/bash: export PATH {HOME}/bin: {PATH}csh/tcsh: setenv PATH {HOME}/bin: {PATH}F Note the syntax for the above commandsF sh/ksh/bash: no spaces except between export and PATHF csh,tcsh: no sign, just a space between PATH and theabsolute pathF all shells: colon(:) to separate different paths andthe variable that is appended toYes, the order matters. If you have a customized version of a softwaresay perl in your home directory, if you append the perl path to PATH atthe end, your program will use the system wide perl not your locallyinstalled version.Introduction to LinuxHPC Training: Spring 2013February 6, 201329 / 80

Variables VRules for Variable Names4Variable names must start with a letter or underscoreNumber can be used anywhere elseDO NOT USE special characters such as @, #, %, Case sensitive5Examples123Allowed: VARIABLE, VAR1234able, var name, VARNot Allowed: 1VARIABLE, %NAME, myvar, VAR@NAMEAssigning value to a e valueexport name valueset name valuesetenv name valuesh,ksh,bash THERE IS NO SPACE ON EITHER SIDE OF csh,tcsh space on either side of is allowed for the set commandcsh,tcsh There is no in the setenv commandIntroduction to LinuxHPC Training: Spring 2013February 6, 201330 / 80

Variables VIExerciseCreate two shell variables containing1 your namee.g. MYNAME Alex2 a standard greetinge.g. Greet HelloWe’ll make use of this variables in a few slides when we learn somebasic commands.Introduction to LinuxHPC Training: Spring 2013February 6, 201331 / 80

Basic CommandsWhat is a command and how do you use it?command is a directive to a computer program acting as an interpreterof some kind, in order to perform a specific task.command prompt (or just prompt) is a sequence of (one or more)characters used in a command-line interface to indicate readiness toaccept commands.Its intent is to literally prompt the user to take action.A prompt usually ends with one of the characters , %, #, :, and oftenincludes other information, such as the path of the current workingdirectory.F Virtual Image: [user@localhost ] F Mac OSX in tcsh: [c8-bc-c8-ee-b8-9e: ] apacheco%Each command consists of three parts: name, options, arguments[user@localhost ] command options argumentsIntroduction to LinuxHPC Training: Spring 2013February 6, 201332 / 80

Commands (contd)How to get more information with Linuxman show the manual for a command or program.The manual is a file that shows you how to use the command and listthe different options for the command in question.Usage: man [command]Example: man lsapropos shows you all of the man pages that may shed some light ona certain command.Usage: appropos [keyword]Example: appropos editorIntroduction to LinuxHPC Training: Spring 2013February 6, 201333 / 80

Commands (contd)Print to screenecho arguments will print arguments to screen or standard output.arguments can be a variable or string of characters including numbers.Examples:12echo LD INCLUDE PATHecho Welcome to HPC TrainingExercisePrint out the variable you created a few slides backecho MYNAMEecho GreetCombine and print your name and the greetingecho Greet MYNAMEWhat is the output of the following command?echo Greet MYNAME, Welcome to HPC TrainingIntroduction to LinuxHPC Training: Spring 2013February 6, 201334 / 80

Commands (contd)Where are you at?pwd: prints working directory.Usage: pwdExample: pwdHow to move around the file systemcd: allows one to change directory i.e.argument is the path (relative or absolute) of the directory you want tochange toUsage: cd [destination]Example: cd /tmpThe default destination directory is your home directory.i.e. If you type cd, you will end up in your home directory.If you want to go back to the previous directory, type cd -Introduction to LinuxHPC Training: Spring 2013February 6, 201335 / 80

Commands (contd)Listing Directory Contentsls: list contents of the current or another directory.Usage: ls options path Example: lsThe current working directory is the default path.To list contents of another directory specify the path, relative or absoluteCommon options to the ls command12345-l: show long listing format-a: show hidden files-r: reverse order while sorting-t: show modification times-h: use file sizes in SI units (bytes, kilobytes, megabytes etc )default is bytesIntroduction to LinuxHPC Training: Spring 2013February 6, 201336 / 80

Commands (contd)Create a Directorymkdir: create a directoryUsage: mkdir options directoryname Example: mkdir -p HOME/test/testagainBy default, the directory is created in the current directory or in a pathrelative to the current directoryThe -p option will create intermediate directories if they do not exist.e.g. If the directory test does not exist in HOME, thenmkdir HOME/test/testagain will fail.The -p option will create the test directory within HOME and thencreate testagain within the newly created test directoryIntroduction to LinuxHPC Training: Spring 2013February 6, 201337 / 80

Commands (contd)Copying Files and Directorycp: copy a file or directoryUsage: cp options source(s) destination Example: cp HOME/.bashrc ././tmpCommon options to cp command:123-r: copy recursively, required when copying directories.-i: prompt if file exists on destination and can be copied over.-p: preserve file access times, ownership etc.If there are more than one source file, then the last file is the destination.If the source(s) is(are) a file(s) and the destination is a directory, thenthe file(s) will be copied into the directorye.g. cp file1 file2 dir1dir1 will contain the files file1 and file2If dir1 is a file, then dir1 will be the same as file2Introduction to LinuxHPC Training: Spring 2013February 6, 201338 / 80

Commands (contd)Removing Files and Directoryrm: remove/delete a file or directoryUsage: rm options file or directory Example: rm ././tmp/.bashrcCommon options to cp command:123-r: remove recursively, required when copying directories.-i: prompt if file really needs to be deleted-f: force remove overrides the -i optionBE CAREFUL WHILE USING THE rm COMMAND,DELETED FILES CANNOT BE RECOVEREDTo be on the safe side, create an alias to the rm command and only usethe -f option only if you are sure you want to delete the file or directorysh/ksh/bash: alias rm "rm -i"csh/tcsh : alias rm ’rm -i’delete empty directories using the rmdir command.Introduction to LinuxHPC Training: Spring 2013February 6, 201339 / 80

Commands (contd)Moving or Renaming Files/Directoriesmv: move or rename a file or directoryUsage: mv options source destination Example: mv test test1If there are more than one source file, then the last file is the destination.Use the -i option to prompt if a file or directory will be overwritten.If the source(s) is(are) a file(s) and the destination is a directory, thenthe file(s) will be copied into the directory.e.g. mv file1 file2 dir1dir1 will contain the files file1 and file2If dir1 is a file, then dir1 will be the same as file2 and file1 willbe deleted.Introduction to LinuxHPC Training: Spring 2013February 6, 201340 / 80

Commands (contd)Display Contents of a filecat: Show contents of a file.more: Display contents one page at a time.less: Display contents one page at a time but allow forward/backwardscrollingless more or less is more, more or lessUsage: cat/more/less options filename Example: cat .bashrcTo scroll forward in more or less, use the space bar, CNTRL-f/d or"Page Down" key.To scroll backwards in less use CNTRL-b/u or "Page Up".Introduction to LinuxHPC Training: Spring 2013February 6, 201341 / 80

Commands (contd)passwd: change password (does not work on LSU HPC and LONIsystems)chsh: change default shell (does not work on LSU HPC and LONIsystems)df: report disk space usage by filesystemdu: estimate file space usage - space used under a particulardirectory or files on a file system.sudo: run command as root (only if you have access)mount: mount file system (root only)umount: unmount file system (root only)shutdown: reboot or turn off machine (root only)top: Produces an ordered list of running processesfree: Display amount of free and used memory in the systemfind : Find a filealias: enables replacement of a word by another stringIntroduction to LinuxHPC Training: Spring 2013February 6, 201342 / 80

Commands (contd) Ivi: Edit a file using VI/VIMemacs: Edit a file using Emacsfile: Determine file typewc: Count words, lines and characters in a file wc -l .bashrcgrep: Find patterns in a file grep alias .bashrcawk: File processing and report generating awk ’{print 1}’ file1sed: Stream Editor sed ’s/home/HOME/g’ .bashrcset: manipulate environment variables set -o emacstouch: change file timestamps or create file if not presentdate: display or set date and timeIntroduction to LinuxHPC Training: Spring 2013February 6, 201343 / 80

Commands (contd) IIln: Link a file to another file ln -s file1 file2which: shows the full path of (shell) commandswho: show who is logged onwhoami: print effective useridfinger: user information lookup programwhatis: display manual page descriptionsTo learn more about these commands, type man command on the commandpromptIntroduction to LinuxHPC Training: Spring 2013February 6, 201344 / 80

Remote SystemsHow to Login to remote systems?Most Linux/UNIX systems allow secure shell connections from othersystems.e.g. You need to login using ssh to the LSU HPC and LONI clusters.Usage: ssh username @ remote host Example: ssh apacheco@eric.loni.orgIf your local machine is a UNIX-like system i.e. Linux, Mac OSX, BSD,AIX, Solaris etc and your username on the local machine is the sameas that of the remote machine, thenyou can omit the username @ part of the argument.i.e. ssh remote host If the remote machine is listening to ssh connections on a non defaultport (i.e. different from port 22) add -p port number optioni.e. ssh -p port number user @ remote host Introduction to LinuxHPC Training: Spring 2013February 6, 201345 / 80

How do I copy files between two systems? ICopy files over the Internetscp is a command to copy files/directories between two *nix hosts overthe SSH protocol.Usage: scp options user @ host :/path to source \ user @ host :/path to destinatione.g. You want to copy files between Eric Loni Cluster and your LinuxDesktop/Laptopscp apacheco@eric.loni.org:/work/apacheco/somefile .scp -r Public apacheco@eric.loni.org:/work/apacheco/You can omit the user @ part of the argument if the username is thesame on both systems.You can omit the user @ host : for your local machine.Common options are -r and -p, same meaning as cp.add -P port number option for non default ports.Introduction to LinuxHPC Training: Spring 2013February 6, 201346 / 80

How do I copy files between two systems? IIrsync is another utility that can be used to copy files locally andremotely.Usage: rsync option source destination It is famous for its delta-transfer algorithmi.e. sending only the differences between the source files and the existingfiles in the destination.Rsync is widely used for backups and mirroring and as an improvedcopy command for everyday use.Common options:1234567-a:-r:-v:-z:-u:-t:-n:archive moderecurse into directoriesincrease verbositycompress file data during the transferskip files that are newer on the receiverpreserve modification timesdry-run, perform a trial run with no changes madeExample: rsync -avtzu eric.loni.org: /* .Introduction to LinuxHPC Training: Spring 2013February 6, 201347 / 80

Compressing and Archiving Files IFile CompressionQuite often you need to compress and uncompress files to reducestorage usage or bandwidth while transferring files.*nix systems have built-in utilities to compress/uncompress filesCompressUncompressgzip, zip, bzip2gzip READMEgunzip, unzip, bunzip2gunzip README.gzGzipped files have an extension .gz,.z or .Zzipped files have an extension .Zip or .zipBzipped files have an extension .bz2, .bzTo compress/uncompress files recursively, use the -r option.To overwrite files while compressing/uncompressing, use the -f option.Introduction to LinuxHPC Training: Spring 2013February 6, 201348 / 80

Compressing and Archiving Files IITape Archive*nix provides the tar package to create and manipulate streamingarchive of files.Usage: tar options file patterns file is the name of the tar archive file, usually with extension .tarpatterns are pathnames for files/directories being archivedCommon options123456-c:-x:-z:-j:-t:-v:create an archive fileextract to disk from archivefilter the archive through gzip (adds/requires extension .gz)filter the archive through bzip2 (adds/requires extension .bz2)list contents of archiveverbosely list files processede.g. tar -cvzf myhome.tar.gz {HOME}/*This becomes useful for creating a backup of your files and directoriesthat you can store at some storage facility e.g. external diskIntroduction to LinuxHPC Training: Spring 2013February 6, 201349 / 80

I/O RedirectionThere are three file descriptors for I/O streams123STDIN: Standard InputSTDOUT: Standard OutputSTDERR: Standard Error1 represents STDOUT and 2 represents STDERRI/O redirection allows users to connect applications : connects a file to STDIN of an application: connects STDOUT of an application to a file: connects STDOUT of an application by appending to a file: connects the STDOUT of an application to STDIN of anotherapplication.Examples:12345write STDOUT to file: ls -l ls-l.outwrite STDERR to file: ls -l 2 ls-l.errwrite STDOUT to STDERR: ls -l 1 &2write STDERR to STDOUT: ls -l 2 &1send STDOUT as STDIN: ls -l wc -lIntroduction to LinuxHPC Training: Spring 2013February 6, 201350 / 80

File Permissions IIn *NIX OS’s, you have three types of file permissions123read (r)write (w)execute (x)for three types of users123usergroupworld i.e. everyone else who has access to the systemdrwxr-xr-x.-rw-rw-r- blicREADMEThe first character signifies the type of the filed for directoryl for symbolic link- for normal fileIntroduction to LinuxHPC Training: Spring 2013February 6, 201351 / 80

File Permissions IIThe next three characters of first triad signifies what the owner can doThe second triad signifies what group member can doThe third triad signifies what everyone else can doRead carries a weight of 4Write carries a weight of 2Execute carries a weight of 1The weights are added to give a value of 7 (rwx), 6(rw), 5(rx) or 3(wx)permissions.chmod is a *NIX command to change permissions on a fileTo give user rwx, group rx and world x permission, the command ischmod 751 filenameIntroduction to LinuxHPC Training: Spring 2013February 6, 201352 / 80

File Permissions IIIInstead of using numerical permissions you can also use symbolicmodeu/g/o or a user/group/world or all i.e. ugo /- Add/remove permissionr/w/x read/write/executeGive everyone execute permission:chmod a x hello.shchmod ugo x hello.shRemove group and world read & write permission:chmod go-rw hello.shUse the -R flag to change permissions recursively, all files anddirectories and their contents.chmod -R 755 {HOME}/*What is the permission on {HOME}?Introduction to LinuxHPC Traini

Shells are how command-line interfaces are implemented in Linux/Unix. Each shell has varying capabilities and features and the user should choose the shell that best suits their needs. The shell is simply an application running on top of the kernel and provides a powerful interface to the system.