Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
38 views
Linux
Uploaded by
iamdc1848
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Linux For Later
Download
Save
Save Linux For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
38 views
Linux
Uploaded by
iamdc1848
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Linux For Later
Carousel Previous
Carousel Next
Save
Save Linux For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 304
Search
Fullscreen
4 Q SPARK TECH CONSULTANCY SERVICES &buuus Cdoddd ~ em, ie Jivvesveticeddals INDEX ‘St No Command Name Priority Page No_ | Introduction ae 1 Chmod [ra B 2 ‘Umask P2 ema 3 Chown PL 7 | 4 herp PL 19 5 Date P2 ~ 20 6 Cal P2 2 7 Uname PL sin 8 Hostname P2 28 9 Sudo , su [rn 31 10 id P2 34] uw 1s PL 36 2 ed = PL 40 2B pwd PL 43 14 mkdir PL aad 15 rmdir [en 46 16 rm PL 48 7 which P2 50 18 whereis P2 51 19 whoami PL 52 20 who P2 53 2 users Pz 55 22 Cattac PL 56 B touch PL 61 2 nia P2 69 5 stat P2 7 26 PL 2 27 mv PL 76 28 ssh PL 3 29 scp. PL 82 30 ‘crontab PL 86 31 of PL 95 32 du PL 98 33 iff PL 102 34 syne PL 107 35 grep PL a4 36 grap PL 122 37 ferep PL 125 38 head PL 129 39 tail, PL 132 40 Morejess PL 134 a Vi editor PL 135+ SPARK TECH CONSULTANCY SERVICES e e c [sro Command Name Priority Page No _| cn 2 we PL 140 a3 be - Pz 145 cr aa test P3 154 ce 45, ‘dear PL 158 ie 26 cut Bt 159 - a7 free PL 164 1 48 vmstat PL 166 a “3 ft PL 169 © 50 kil PL 175 | SL Bate PL | | Gy 52, In ca 182 | c: 53 ‘mail : ‘emer 391 54 passwd PL c ' 35 ps PL | 36 Fuser °2 ¢ 37 Top PL ec 38 Shutdown reboot P2 | 59 Aik PL Cc © Echo P2 Gy Print? PZ © a Tee PL e GI ifeonfig P3 6a Netstat °2 i . 6 Nslookup P2 c 66 Ping PL ] Gl Hostname P2 C 8 Sed PL c | ‘Transiate,tr PS - 70 Sort PL e a Spit P3 72 Salplus: PL e B ‘Uname PL 74 Uptime P2 S 75 zp PL e 76 Gzip PL 77 Tar Pa e c © © c c ¢ ° c So =SparkTech Consultancy Services Introduction ‘The difference between application, program, software? Software. Software is a development process which converts the imaginaries into reality by writingcomes set of programs. Application- A program or group of programs that is designed for the end user. Application software (an application) is a set of computer programs designed to permit the user to perform a group of coordinated functions, tasks, or activities. Application software cannot run on itself but is dependent on system software to execute, Program: A set of instructions telling a computer wht to do. “All applications are programs, but a program is not necessarily an application. For example, Windows Media Player and Firefox, are applications. They have a Graphical User Interfac software System Software Application Sottware Internet software [Used to develop functions. (Used to develop [Used ta develop ‘of hardware devices } ‘organizational oriented Distributed epplications ] Applications me pa {Ierooft} [Sun Micro Systems Product Based Companies Standard Distributed Applications Applications 1. Product based mean universally used |» trea Disk ww Ex Microsoft word 2. Project Based mean L> Not sharable Shoreble Ee sper-market ‘Above Sai Motors, Near selfie point Bhumkar Chauk, Narhe Pun Contact No: 8855032507 , 8855901508SparkTech Consultancy Services In IT we develop two types of applications. They are stand alone applications and distributed applications. ‘A stand alone application is one which runs in the context of local disk. All stand alone applications are not sharable. System software and pplication software comes under stand alone plications © System software is used for developing functionality of hardware devices. Examples are C and ALP (Assembly Language Programming). ‘+ Application software is used for developing organizations oriented applications. This is also known as backend softwore’s. Examples are dbase, dbase Ill plus, FoxPro, oracle versions released till now. + Internet software is used for developing distributed applications. A distributed application is one which can be accessed across the globe. Distributed application is also one which runs in the contest ofthe World Wide Web. To develop distributed applications we must use client-server architecture In client-server orchitecture we must hare at least two programs they are client program and server program. A client program is one which always makes a request to get the service from the server. A server program is one which will do three operations receiving the request from client, processing the client request and sending the response to the client. All the above three operations are performed by the server concurrently. in order to exchange the data between client and server we must use a protocol called http (hypertext transfer protocol). Protocol is a set of values which are defined to exchange the data between client and server either locally or remotely. In order to develop distributed applications, two software companies came forward whose names are Microsoft System and Sun Micro System. (Office No- A/201 Vithhal Complex, Above Sai Motors, Near selfie point Bhumkar Chauk, Narhe Pune -411058 Contact No: 8855032507 , 8855901508 Page 2SparkTech Consultancy Services ‘As per the sun micro system standard the java language is divided into three types. 1) J2SE/SE{java 2 standard edition) 2) J2E6/sEE(java 2 enterprise edition) 3) J2ME/sME{java 2 micro edition) 22st By using j2se we are able to develop the standalone applications. Ec: notepad, WordPad, paint, Google Talk....ete Standalone applications:- 1). Standalone applications are the java applications which don't need the client server architecture. 2) The standalone applications applicable for the only one desktop hence itis called desktop applications or window based applications, 3) For the standalone applications doesn’t need internet connections. 4)_Itis a focal application it doesn’t need any other external application support. '5)_ This type of the applications we cam launch by using the command line or by using the executable jar Client Database REE By using j2ee we are able to develop the web based applications. Ex Gmail, yahoo mail, bank, reservation vnunet ‘Web-applications:- 41) Web applications are the java applications which needs client and server concept. 2), Web applications must need the internet connections to access the application. 3). The application which is present in the internet is called the web application. 4) Web application can be launched by using HTTP driven, HTTP request sent to the Servlet present in the server side. (fice No-A/20% Vital Complex, Above So Motors, Near selie pain Bhumkar ChaoleNavhe Pune a1 100 Contact No: 8855032507, 8835901508 Page 3SparkTech Consultancy Services Web application architecture: Client server database itt | foauest og < cs 8 Hibernate vencty J] Usedto y ‘response store the data L___ lent ‘The person who is sending the request is called client. Al web browsers come unde the clients cr InternetExploral, MozlaFrefox, opera......ete Server: ‘The server contains the applications. The main purpose of the server is It will contain the application, Take the request from the client. © Based on the taken request it will identify the project resource and execute that project, By executing the project some response will be generated that response is dispatched to the client browser. xc- Tomcat GlassFish, WebLogic JBOSS, WebSphere......ete DataBase:- DataBase is used to store the det ete. x:- Oracle MySql ke client details, application details, registration ete By using j2me we are able to develop the applications that applications only run on mobile devices. ‘Asa software engineer we must know these technologies: HTML(Hyper Text Markup Language): It's used for web pages designing, Introduced by World Wide Web Consortium and developed by Tm Bernestee Te —— S . Above Sai Motors, Near selfie point Bhumkar Chauk, Narhe Pune -#11058 Contact No: 8855032507 , 8855901508 Page 4 Office No- A/201 Vithhal ComplSparkTech Consultancy Services There are three levels of support Level 1Receiveing issues over phone /emall/ apps , registering them int issue management appstTcketng tools ike ~ BMC Remedy, HPSM, Clarify CRM Bridge, Service Now ete) and escalating them Itis known as Problem Managment and the objects to see that the issue gets resolved. Level 2: Level 1 will escalate sues to Level 2 Level 2 should be having rights and privileges to make changes to the infratructure, They wilinvesizate the issue and take actions to fx the issue if they are privileged to do so. They may have to escalate to other L2 teams. Li has to track the process. Level 3 Amissue reaches this team is the fix involves making changes to the IT infrastructure or code and would need an approval from various Administrative Heads Application Support Application Support could involve all the three levels of support. There is a support team for as 2 of Applications. L1 and (2 Support might involve investigating and fixing issues that may impact a particular User, This could require the support person to use admin privileges within the App or through database or operating system level. The actual ob can be delegated to relevant support Team. Level 3 in ‘Application Support involves development work and one may be asked to fix bugs in the code that may have been raised by L1 or L2. They may also be asked to carry out minor mods or enhancements in code as asked by the Busines. Product Support ‘This involves all levels of support. One can have more than one clients. Itis provided to those clients who have warranty or have support contracts. The nature of support could be product related, operating system issues or software related. Knowledge of the product is essential Office No- A/201 Vithhal Complex, Above Sai Motors, Near selfie point Bhumkar Chauk, Narhe Pune 411058 Contact No: 8855032507 , 8855901508 Page 5SparkTech Consultancy Services Technical Support Again this involves all levels of support. Unlike Product Support, Technical Support could involve many products, software, operating systems. Itis necessary to have the knowledge of the domain in which tone is working. ifthe support relates to networking then one is expected to know all about networking and the operation of individual networking device Suppose: You are @ company ABC'td with @ product which islets say MS-Office. Now you sold these product toa company XYZ td Now XYZ is facing issues during installation of MS-Office in their ofice ‘They wil contact the technical support to resolve their queries if they are not able to solve ther issues it will be moved to the next level whichis product support which finds out the issue is caused by MS-Word so they will contact the MS-word application support team which will work n the issues with MS-word to fix the issue facing by XVZItd. Introduction to Linux Linux Is an open source operating system, Similar to any other operating systems like Windows, MAC ‘etc. An operating system is a program which manages the communication between user software and hardware. ‘There are following major parts in a Linux system: kernel — A Linux Kernel is the core of any operating system, which directly interacts with the hardware. It manages all the system resources like “Memory”, "CPU", “Processes” and Attached peripheral devices to the system. Office No- A/201 Vithhal Complex, Above Sai Motors, Near self point Bhumkar Chauk, Narhe Pune ~411058 Contact No: 8855032507 , 8855901508 Page 6SparkTech Consultancy Services Bootloader ~ The Bootloader also called Boot Manager. A program that handles the boot process for any Linux computer. It loads the operating system from the storage device to memory. Shell ~ A shell is @ command line interpreter, which provides the directly interacts users via standard input devices like a keyboard. Desktop Environment ~ These provide the Graphical interface of a shell to users to work. This is Similar to Windows desktop environment, Linux Architecture The Linux system works basically on 4 layers. Fitst view the diagram below, which is showing the architecture of a Linux System. Linux System Architecture Office No- 1/201 Vithhal Complex, Above Sat Motors, Near selfie point Bhumkat Contact No: 8855032507 , 8855901508SparkTech Consultancy Services Hardware ~ Hardware consists ofall physical devices attached to the System. For example: Hard disk drive, RAM, Motherboard, CPU etc Kernel - Kernel is the core component for any (Linux) operating system which directly interacts with the hardware, ‘Shell ~ Shell is the interface which takes input from Users and sends instructions to the Kernel, Also ‘takes the output from Kernel and send the result back to output shell, Applications - These are the utility programms which runs on Shell, This can be any application like Your web browser, media player, text editor etc. Linux system is basically divided in three major components: Linux File System (LFS), Shell and Kernel. Kernel is the core program which manages system hardware devices. Shell provides user interface to run the commands. File system organizes the data in systematic way. Collectively LES, Shell and kernel provides @ way to interact with system and an environment to run commands and manage data. Linux File System (LFS) Linux accesses every object as file, Files are systematically organized in directories. Linux file system starts with the root (/) directory. All files and directories are created and managed under this (root) directory, Since root directory stands on the top of file system, it has no parent directory. Besides root directory, every directory has a parent directory. Linux allows us to create as many files and directories as we want. We can create files under the existing directories or may create new directories System Directories System directories contain files, software, applications and scripts which are required to run and maintain the Linux. System directories are automatically created during the installation Following figure illustrates same important system directories with their location in LFS. Office No- A/201 Vithhal Complex, Above Sai Motors, Near selfie point Bhumkar Chauk, Narhe Pune ~411058 Contact No: 3855032507 , 8855901508 Page 8SparkTech Consultancy Services Linux Directory Structure (File System Structure) Advertisements DirectoryDescription / First directory in Linux File System. Itis also known as root directory or main directory. All files ‘and directories are created and managed under this directory. ‘home Default directory for user data. Whenever we add a new user, Linux automatically creates a home directory matching with his username in this directory. Linux puts user in his home directory just after the login. /root This is the home directory of root user. Root user is the super user in Linux. For security reasons, Linux creates a separate home directory for the root user. [rin This directory contains standard commands files. Commands stored in this directory are available for all users and usually do not require any special permission to run. /sbin This directory contains system administration commands files. Commands stored in this. directory are available only for super users and usually require special privilege to run. Office No- A/201 Vithhal Complex, Above Sai Motors, Near selfie point Bhumkar Chauk, Contact No: 8855032507 , 8855901508 Page 9SparkTech Consultancy Services Just This directory contains user application software files, third party software and scripts, document files and libraries for programming languages. Jvat This directory stores variable data files such as printing jobs, mail box etc. Jetc This directory contains system configuration files. [eoot This directory contains Linux boot loader files, Jmnt This directory is used to mount the remote file system and temporary devices such as CD, DVD and USB. [dev This directory contains device files. Usually files in this directory are dynamically generated and should be never edited. [tmp This directory provides temporary location for applications. Unix vs Linux — Difference between Unix and Linux. Rca eae ene Unix primarily uses Command Line Interface. Linux OS is portable and can be executed in different Hard Unixis not portable. Drives. a Unix has a rigid requirement of the Hardware. Hence, cannot be installed on every other Uinuxis very flexible and can be installed on most of the Home Based Pes. machine. Linux is mainly used in Home Based PC, Mobile Phones, Unix is mainly used in Server Systems, Desktops, etc. Mainframes, and High-End Computers. Different Versions of Linux are: Ubuntu, Debian, OpenSuse, Different Versions of Unix are: AlS, HP-UX, BSD, (Office No- A/201 Vithhal Complex, Above Sai Motors, Near selfie point Bhumkar Chauk, Narhe Pune -41 1058, Contact No: 8855032507 , 8855901508 Page 10SparkTech Consultancy Services Redhat, Solaris, et. Iris, ete Linux Installation is economical and doesn't require much Unix installation is comparatively costlier as it. specific and high-end hardware. requires more specific hardware circuitry. The filesystems supported by Linux are as follows: xfs, ramfs, nfs, vfat, cramfsm ext3, ext, ext2, extl, ufs, autofs, devpts, ntfs ‘The Filesystems supported by Unix are as follows: 2fs, js, hx, eps, xfs, aps, xfs, vis, Linux is developed by an active Linux Community worldwide. _Unixis developed by AT&T Developers. Processes in linux A process refers to a program in execution; t's a running instance of a program. its made up of the program instruction, data read from files, other programs or input from a system user. Types of Processes There are fundamentally two types of processes in Linux: + Foreground processes (also referred to as interactive processes) ~ these are initialized and controlled through a terminal session. In other words, there has to be a user connected to the system to start such processes; they haven't started automatically as part of the system functions/services ‘+ Background processes (also referred to as non-interactive/automatic processes) ~ are processes not connected to a terminal; they don't expect any user input. What is Daemons These are special types of background processes that start at system startup and keep running forever asa service; they don’t die. They are started as system tasks (run as services), spontaneously. However, they can be controlled by a user via the init process. 11058 Contact No: 8855032507 , 8855901508 Page 11. Office No- A/201 Vithhal Complex, Above Sai Motors, Near selfie point Bhumkar Chauk, Nathe PuneSparkTech Consultancy Services Process State admitted interrupt erminated) ag read runnin: exit Cieaay ) — —.Cruming) scheduler dispatch _ vO vO or or event wait event completion Coating) : States of a Process in Linux During execution, a process changes from one state to another depending on its environment/circumstances. In Linux, a process has the following possible states: = Running ~here it’s either running itis the current process in the system) or it’s ready to run (it’s waiting to be assigned to one of the CPUs) ‘+ Waiting ~in this state, a process is waiting for an event to occur or for a system resource, Additionally, the kernel also differentiates between two types of waiting processes; Interruptible ‘waiting processes ~ can be interrupted by signals and uninterruptible waiting processes ~ are ‘waiting directly on hardware conditions and cannot be interrupted by any event/signal. * Stopped — in this state, a process has been stopped, usually by receiving a signal. For instance, a process that is being debugged. = Zombie ~ here, a process is dead, it has been halted but it’s still has an entry in the process table, Office No- A/201 Vithhal Complex, Above Sai Motors, Near selfie point Bhumnkar Chauk, Narhe Pune -411058 Contact No: 8855032507 , 8855901508 Page 12,SparkTech Consultancy Services 1. Chmod Command ‘The chmod command is used to change the file or directory access permissions. To know about the access permissions of a file or directory, use the Is -| command as shown below: $154 sample.sh srwe-rw-t-- 1 matt deploy 94 Oct 4.03: sample.sh Here in the above example: Use matt has the read, write and execute permissions on the file, Group deploy has read and write permissions. Others have only the read permission, File and Directory permissions: Every Linux system have three types of owners 1. User: A user is the one who created the file. By default, whosoever, creates the file becomes ‘theowner of the file. A user can create, delete, or modify the file. 2. Group: A group can contain multiple users. All the users belonging to a group have same. accesspermission for a file, 3. Other: Any one who has access to the file other than user and group comes in the categoryofother. Other has neither created the file nor is 2 group member. ‘There are three different permissions. They are: + Read (4): Permitted to read the contents of the file. In case of directory, you can view all the files and sub-directories in that directory. + Write (2): Permitted to write to the file. In case of directory, you can create files and sub- + Exeter the lesa reprom/shall et Inet of resto, You can enero that directory | permission ‘Value ‘ona file ona directory [Firesd) 4 [read ie content feat) wad Greclony content fa) | wharte) | 2 | change ie convent (i) ereate ein dvecory Rauch) | x (execute) 1 execute the file enter the directory (cd) Here in the above, the numbers in the brackets represents the numeric values for the corresponding permissions. f you want to have a combination of permissions add the required numbers. For example, for read and execute, itis 4¥ Office No- A/201 Vithhal Complex, Above Sai Motors, Near selfie point Bhumkar Chauk, Narhe Pune #11056, Contact No: 8855032507 , 8855901508 Page 13SparkTech Consultancy Services The syntax of chmod command is chmod [options] mode filename ‘THe important options are: -f: recursively change the permissions of a directory. -v: Verbose Chmod Examples in Linux / Unix: 1. Give read, write and execute permissions to everyone. Read, write and execute: 4+2+1=7 $ chmod 777 sample.sh Alternatively, you can use the symbolic representation to give the permissions. chmodugotrwx sample.sh We will see more details about the symbolic representation later. 2. Give read permission to user, write permission to group and execute permi $ chmod 421 sample.sh 3, Recursive permissions to directory To give read and write permissions to all the users to a directory (including files and subdirectories) use the recursive option-R. chmod -R 666 /dir ‘Symbolic Representation of Permissions: ‘The following symbols are used to represent the users, groups and others: Office No- A/201 Vithhal Complex, Above Sai Motors, Near selfe point Bhumkar Chauk, Narhe Pune ~411058 Contact No: 8855032507 , 855901508 Page 14SparkTech Consultancy Services + wsUser + :Group + 0: Others a: All (user, group and others) ‘The following symbols represent the permissions: © riread © wewrite + xzexecute The following symbols represent the permissions grant or revoke: ‘+ +: Additional permissions. Selected permissions are added ‘+ =: Revoke the permissions. Selected permissians are revoked ‘+ =: Specific permissions. Only selected permissions are assigned. Examples: 1. Remove write permission from group $ chmod g-w sample.sh This will only removes the write permission for the group, 2. Add new permission execute to others $ chmodosx sample.sh In addition to the existing permissions, this will add execute permission to others, 3, Give only read permissions to the user $ chmod u=r sample.sh This will remove the existing permissions to the user and gives only write permission to the user. Office No- A/201 Vithhal Complex, Above Sai Motors, Near selfie point Bhumkar Chauk Nathe Pune “411056 Contact No: 8855032507 , 8855901508 Page 15,SparkTech Consultancy Services 2. Umask Command Every file that is created comes with a default set of permissions. If you ever wanted to change that default set of permissions, you can do so with the umask command Default file creation permissions willbe obtained from the umask value. Mask of umask will give the actual permissions. Masks subtract valve from 7 IF umask s 021, then the default file permissions are 7.0,7-2,7-4 ie. 756 are the permissions (rwarxrw-) The current umask value can be had by: $ umask 0227 first O indicate the value is octal umask can be assigned new value by: $$ umask 042, Office No- A/201 Vithhal Complex, Above Sai Motors, Near selfie point Bhumkar Chauk, Narhe Pune -411058 Contact No: 8855032507 , 8855901508 Page 16SparkTech Consultancy Services 3. chown command chown command changes the user and/or group ownership of far given file, The syntax is: 4) chown:To change Owner of the File/Directory Syntax:SchownOwner_Name File/Directory chown owner-user file chownowner-user:owner-groupfile chownowner-user:owner group directory chown options owner-user:owner-groupfile ExamplesFirst, lst permissions for demo.txt, enter. Als demo.txt Sample outputs: ~rw-r--t~ 1 root root 0 Aug 31 05:48 demo.txt In this example change file ownership fo vivek user and list the permissions, run # chownvivek demo.txt #ls-Idemo.txt Sample outputs: -rw-r=~ 1 vivek root 0 Aug 31 05:48 demo.txt In this next example, the owner is set to vivek followed by a colon and a group onwership is also set to vivek group, run: # chown vivekwvivek demo.txt #ls-Ademoaxt Sample outputs: vivekvivek 0 Aug 31.05:48 demo.txt Office No- A/201 Vithhal Complex, Above Sai Motors, Near selfie point Bhumkar Chauk, Narhe Pune -411058 Contact No: 8855032507 , 8855901508 Page 17SparkTech Consultancy Services In this example, change only the group of file. Te do s0, the colon and following GROUP-name ftp are sgiven, but the owner is omitted, only the group of the files is changed: 4H chown :ftp demo.txt \s-1demo.tet Sample outputs: -rwer-r~ 1 vivek ftp 0 Aug 31 05:48 demo.txt Please note that if only a colon is given, or if NEW-OWNER is empty, neither the owner nor the group is changed: # chown: demo.txt In this example, change the owner of /foo to “root”, execute: 4 chown root /foo Likewise, but also change its group to “httpd”, enter: chownroot:httpd /foo Change the owner of /foo and subfiles to “root”, run’ # chown -R root /u ‘Where,-R- Recursively change ownership of directories and their contents. ‘Office No- A/201 Vithhal Complex, Above Sai Motors, Near selfie point Bhumkar Chauk, Narhe Pune ~411058 Contact No: 8855032507 , 8855901508 Page 18SparkTech Consultancy Services 4. cherp To change Group of the File/Directory ‘+ Syntax:$ chgrp Group_Name File/Directory Office No- 4/201 Vithhal Complex, Above Sai Motors, Near selfie point Bhumkar Chauk, Narhe Pune -411058 Contact No: 8855032507 , 8855901508 Page 19SparkTech Consultancy Services 5. Date Command Date command is used to print the date and time in unix. By default the date command displays the date in the time zone that the unix operating system is configured, Date Command Examples: {Write a unix/linux date command to print the date on the terminal? date Mon Jan 23 01:37:54 PST 2012 2. Write aunix/linux date command to set the date in unix? You can change the date and time by using the -s option to the date command. date -s “01/01/2000 12:12:12" 3.date command to display only the date part and ignore the time part? date '+%6m-%d-96Y" 01-23-2012 ‘You can format the output of date command by using the %. Here %m for month, Séd for day and %Y for year. 4.date command to display only the time part and ignore the date part? date '+96H:4MKS! 01-48-45 Office No- A/201 Vithhal Complex, Above Sai Motors, Near selfie point Bhumkar Chauk, Narhe Pune -411058 Contact No: 8855032507 , 8855901508 Page 20Here $6 is for hours in 24 hour format, %M is for minutes and %S for seconds 5. Write a unix/linux date command to format both the date and time part. SparkTech Consultancy Services >date "4%6m-%6d-96Y 96H-96M-%4S! 01-23-2012 01-49-59 Office No- A/201 Vithhal Complex, Above Sai Motors, Near selfie point Bhumkar Chauk, Nathe Pune Contact No: 8855032507 , 8855901508 11058 Page 21SparkTech Consultancy Services 6. Cal Command To display current month's cate EXAMPLES To display current month's calendar sent To display feb 2015 calendar 1234567 15 16 17 18 19 20 21 22 23 24 25 26 27 28 To display complete year calendar. Scat You can print the calendar of the entire current year using the -y option of cal command, Office No- A/201 Vithhal Complex, Above Sai Motors, Near selfie point Bhumkar Chauk, Narhe Pune 411058 Contact No: 8855032507 , 8855901508 Page 22SparkTech Consultancy Services Pores eres cote 3. Print the calendar of a particular month and/or year If you want 1o print the eaenas n month an year. you ean do so by For example. 20 print the calendar of Jiune 2017, you can ase any of the below three + cal 6201 = eal -d 20) labhishek@linuxhandbook:-$ cal 6 2017 rarer tres reas Cord es rr) eee Pa et) Office No- A/201 Vithhal Complex, Above Sai Motors, Near self point Bhumkar Chauk, Narhe Pune -411058 Contact No: 8855032507 , 8855901508 Page 23SparkTech Consultancy Services 4. Print three months view ‘You can print the previous month, current month and the next month's calendar in one go with -2 option. eras) bar TLE ae
ced /nctab>/sctab> /retab>/uctab> Note: Press tab to complete directory name. (Office No- A/201 Vithhal Complex, Above Sai Motors, Near selfie point Bhumkar Chauk, Narhe Pune #11058 Contact No: 8855032507 , 8855901508 Page 42SparkTech Consultancy Services 13. PWD ~ (Present Working Directory) Command = Shows working ie current directory displays your location currently you are working on. It will give the whole path starting from the root ending to the directory e.g- [Spark@admin “]$pwd output - home/spark/Dir1 EXAMPLES 1. Simple usage of pwd(self explanatory) S pwd Jus¢flocalfoin Sed $ pwd Jusrflocal ———— Office No- 4/201 Vithhial Complex, Above Sai Motors, Near selfe point Bhumkar Chauk, Narhe Pune 411056 Contact No: 8855032507 , 8855901508 Page 43SparkTech Consultancy Services 14, mkdir command user can create the directory using Mkdir command in unix. Syntax : $MkdirDirectory_name Example: SMkdirAmit Mikdir command is used to create Unix Directory in present working directory. user wants to create directory on the specific path then just use following syntax Syntax: $WMikdir path/Directory_name Example: $Mkdirusr/bin/Amit ‘The above statement will create directory In usr/bin folder. Mkdir command produces no output if successfully created directory. Creating multiple directories : User can create multiple directories in unix using following command. syntax: $Mkdir directory directory2...directory..n Example: ‘SMkdlir Amit Rahul Above statement will create 2 different directories named ‘Amit’ and ‘Rahul’ in present working directory. Creating Parent directory: ‘Sometimes user wants to create a directory where the specified directory is not exist.Means user Is ‘trying to create parent directory. ‘Smikdir /tmp/Pradnya/Unix mkdir: Failed to make directory "/tmp/Pradnya/Unix"; No such file or directory $ If user is facing above error then user needs to use -p option which is used to create parent directory and all the necessary directories directly. Office No- A/201 Vithhal Complex, Above Sai Motors, Near selfie point Bhumkar Chauk, Narhe Pune -411058 Contact No: 8855032507, 8855901508 Page 44SparkTech Consultancy Services Exampl Smkdir -p /tmp/Pradnya/Unix The above statement will create the directory named ‘Pradnya’ in tmp folder and ‘Unix’ in ‘Pradnya’ folder. Display or list only all directories in Unix Type the following command: SIs-1| grep Aa" is-i | egrep "sd! Or better try the following Is command only to list directories for the current directory: Sis-d*/ Linux Display or list only files ‘Type the following command to display list only files in Linux or Unix: Sis | egrep-v'ad! Sis] egrep-v'ad! Office No- A/201 Vithhal Complex, Above Sai Motors, Near selfie polnt Bhumkar Chauk, Narhe Pune 411056, Contact No: 8855032507 , 8855901508 Page 45SparkTech Consultancy Services 15. rmdir Q. How to delete directories and files in unix/linux Unix provides rmdir and rm commands to remove the directories and files Unixrmdir command syntax rmdir [options] directories The rmdir command options are -p : Removes directory and its parent directories rmdir command examples 1. Write a unix/linux command to remove a directory? ‘The rmdir command deletes only the empty directories. Ifa directory contains files or sub directories, then the rmdir command fails. rmdir docs/ madi jocs/: Directory not empty Here the docs directory is not empty, that is why the rmdir command failed to remove the directory. To remove the docs directory first we have to make the directory empty and then delete the directory, rm doc/* rmdir docs/ We will see later how to remove non-empty directories with a single command. 2. Write a unix/linux command to remove the directory and its parent directories? ‘As mentioned earlier the -p option allows the rmdir command to delete the directory and also its parent directories. -p docs/entertainment/movies/ Office No- A/201 Vithhal Complex, Above Sal Motors, Near selfle point Bhumkar Chauk, Narhe Pune -411058 Contact No: 8855032507 , 8855901508 Page 46SparkTech Consultancy Services ‘This rmdir command removes the docs directory completely. If you don’t use the -p option, then it only deletes the movies directory. 3. Write a unix/linux command to remove directories using pattern matching? You can specify the directory names using the regular expressions and can delete them. rm doc* This rm command deletes the directories like doc, documents, doc_t ete. Now we will see the rm command in unix. ‘Office No- A/201 Vithhal Complex, Above Sai Motors, Near selfie point Bhumkar Chauk, Narhe Pune -411058 Contact No: 8855032507 , 8855901508 Page 47SparkTech Consultancy Services 16. rm command The syntax of rm command is rm [options] [directory|file] The rm command options are Removes all files in a directory without prompting the user. i Interactive: prompts the user far confirmation before deleting a file. Ror: Recursively remove directories and sub directories. ‘The rm command can be used to delete both the files and directories, The rm command also deletes the non-empty directories Unixrm command examples 1. toremove afile? ‘This is the basic feature of rm command, To remove a file, logfile.dat, in the current directory use the below rm command rm logfite.dat 2. to remove all the files in a directory? use the * regular pattern as the file list in rm command for deleting al the files in the current directory. 3. to delete empty directory? The rm command can also be used to delete the empty directory. The command for this is rm docs/ Hf the directory is non-empty, then the above command fails to remove the directories. 4, How to delete directories recursively (delete non empty directories)? Office No- A/201 Vithhal Complex, Above Sai Motors, Near selfie point Bhumkar Chauk, Narhe Pune -#11058 Contact No: 8855032507 , 8855901508 Page 48SparkTech Consultancy Services ‘As mentioned earlier, the -r option can be used to remave the directories and sub directories. rm -r docs ‘This removes the docs directory even if itis non-empty. Office No- \/201 Vithhal Complex, Above Sai Motors, Near selfie point Bhumika Contact No: 8855032507 , 8855901508SparkTech Consultancy Services 17. which Command This tutorial explains Linux “which” command, options and its usage with examples. which — shows the full path of (shell) commands. DESCRIPTION Which command is very small and simple command to locate executables in the system. It allows user to pass several command names as arguments to get their paths in the system. “which” commands searches the path of executable in system paths set in SPATH environment variable. SyNopsis Which [OPTION J[ COMMAND ] options a Print all matching executables in PATH, not just the first. EXAMPLES, 1. Show path of certain commands $ whichlsgdb open grep Pbinfis Jusr/binfgdb Jbinfopen Jbin/erep It locates command names ~ "Is", "gdb", “open” and “grep” specified as arguments to “which” command and displays paths of each executable where it exists in the system, 2. Display all the paths using -a option “which” command gives option “-a” that displays all paths of executable matching to argument, $ whichecho Jusr/sbinfecho Above will search display the executable “echo” from all paths set in $PATH environment variable and displays the first path where echo executable is found. it may be case that executable is placed at other paths of $PATH environment variable as well. To get all paths where executable is present in the system, * option can be used Swhich-aecho Jost/sbinfecho [infecho Rr go Office No- A/201 Vithhal Complex, Above Sai Motors, Near selfie poine Bhumkar Chauk, Narhe Pune -411058 Contact No: 8855032507 , 8855901508 Page 50SparkTech Consultancy Services 18, Whereis Command whereis ~locate the binary, source, and manual page files for a command. DESCRIPTION Whereis command is helpful to locate binary, source and manual pages of commands in the tinux system, SYNOPSIS whereis {-bmsu ] [ MS directory... -f] filename EXAMPLES 1, When you want to find out where a specific Unix command exists (for example, where does Is command exists?), you can execute the following command $ whereists \s: /bin/Is/usr/share/man/mant/is.1.gz /ust/share/man/manip/is.1p.gz Tihco Nov A/D01 Vial Complex Above Si Novos Near sellepontBhumlor Chaul Nevhe Pune 11050 Contact No: 855032507 , 8855901508 Page StSparkTech Consultancy Services 19. whoami Command Synopsis: \whoami [OPTION]. It prints the user name associated with the current effective user 1D, Same as id -un command, Example : $ whoami Office No- A/201 Vithhal Complex, Above Sai Motors, Near selfie point Bhumkar Chauk, Narhe Pune -411058 Contact No: 8855032507 , 8855901508 Page 52SparkTech Consultancy Services 20. who ‘who — Displays who is logged an to the system, Description : who command can list the names of users currently logged in, their terminal, the time they have been logged in, and the name of the host from which they have logged in, Usage who [options] [file] Options : -a,~all Same as using the options -b -d -login -p-r-t-T-v. -b, boot Display the time of the last system boot. Print the idle time for each user, and the process ID. Examples : 1. Print Current user's username $ who am i abed 2. Display the username, line, and time of all currently logged-in sessions $who lucypts/12014-01-1722:42(:0.0) psmithpts/22014-01-18 09:30(:0.0) alanpts/32013-12-25 08:52(:0.0) neilpts/42014-01-05 15:33(:0.0) marthapts/02013-03-04 22:05 (:0.0) 3. Get the time of last system boot This is done using the -b option. Swho-b system boot 2014-03-07 05:32 4. Get number of users logged-in and their user names This is done using the -q option. $who-g abedefghi Hserse3 Office No- A/201 Vithhal Complex, Above Sai Motors, Near self point Bhumkar Chauk, Narhe Pune -41 1058 Contact No: 8855032507 , 8855901508 Page 535. Get all the information This is done using the -a option. Swho-a system boot 2014-03-07 05:32 run-level22014-03-07 05:32 LOGIN. tty4 2014-03-07 05:3213091 LOGIN ttyS 2014-03-07 05:3213134 LOGIN tty2 2014-03-07 05:32132i LOGIN tty3 2024-03-07 05:321324% LOGIN. tty6 2014-03-07 05:321327% LOGIN. tty 2014-03-07 05:321492% abe +ty? —-2014-03-0705:33 old 1619(:0) def + >pts/02014-03-07 06:47 2336(:0.0) ghi + pts/12014-03.07 07:58 2336(:0.0) SparkTech Consultancy Services ——————$ ‘Office No- A/201 Vithhal Complex, Above Sai Motors, Near selfie point Bhumkar Chauk, Narhe Pune 411058 Contact No: 8855032507 , 8855901508 Page 54SparkTech Consultancy Services 21, users Command users print the user names of users currently logged in to the current host Example: List logged in users S users abe Note : As only one user is logged on, hence only one username is displayed, else a space seperated list of users is displayed “Office No- A/201 Vithhal Complex, Above Sai Motors, Near selfie point Bhumkar Chauk, Nathe Pune -411058 Contact No: 8855032507 , 8855901508 Page 55,SparkTech Consultancy Services 22.cat , tac command Cat{concatenate) command is very frequently used in Linux. treads data from the file and gives their content as output t helps us to create, view, concotenate files. So let us see some frequently used cat commands # catcoptions>
Exampleit Create anew file using ‘cat> (filename Let's suppose | want to create anew file with name ‘inux_world. Type the following eat command followed by the text you want in to insert in the file, Make sure you type ‘Ctri-d’ at the end to save the file. fiero cea Cees os Tee ee aT Example:2 View the Contents of a File. To display or view the contents of a file using cat command use the below syntax 4 cat {file_name} Let's display the contents of linux_world file. Gece Pea ere Thanks ences SS qe i iq Office No- A/201 Vithhal Complex, Above Sai Motors, Near selfie point Bhumkar Chauk, Narhe Pune -411058, Contact No: 8855032507 , 8855901508 Page 56SparkTech Consultancy Services Example:3 View the Contents of Multiple Files [root@linuxtechi “} catlinux_worldlinux distributions /etc/ Above command will display output of three files on the terminal. Example:4 Display the output of a file using page wise. For example if we have a big file whose contents can't be display at once on the screen , in that case we can use more and less command with cat to view the contents page wise cleo Eee ees ecco Lee ee Example:S cat command without filename arguments if we don’t specify any arguments in the cat command then it will read the inputs from the keyboard attached to the system. Type some text after entering the cat command, ore Ct eee cee) Now press ‘Ctrl-d to inform cat that it has reached end of fle (EOF). In this case it will display the line of text twice because it copies std input to std output. Example:6 Display the contents of a file with Line Numbers Office No- A/201 Vithhal Complex, Above Sai Motors, Near selfie point Bhumkar Chauk, Narhe Pune -411058 Contact No: 8855032507 , 8855901508 Page 57SparkTech Consultancy Services eo cs eee] See ee ere tes Pai recone Ly tn case if your file has blank lines , then above command will also display the number of blank lines as, well, so to remove the numbering of blank lines , we can use “-b' option in place of ‘sn’ in the above command, Example:7 Copy the contents of One file to Another file, Using greater than ‘>’ symbol in cat command we can copy the contents of one file to another , example is shown below erred Example:8 Appending the contents of one file to another. Using double greater than symbol ‘>>'in cat command we can append the contents of one file to ‘another. Example is shown below : cote Above Command will append the contents of /etc/passwd file to linux_text file at the end. Now we can verify the contents of linux_text file ——$——————————— Office No- A/201 Vithhal Complex, Above Sai Motors, Near selfie point Bhumkar Chaulk, Narhe Pune -411058 Contact No: 8855032507 , 8855901508 Page 58SparkTech Consultancy Services es era esc c Coe Cetah Caeser Cwet ty areca Reece eee Sr er SUry SUE Nea Caes 1) Pacers Rae ewate Eeyore ESCA n WESCvL Ss Dice Lee SO aera SELES eee CTA Fre Rear CSer te ftp:x:14:50: FTP User: /var/ftp:/sbin/nologin Treen eres career Ere ree aoe Se eis poner) wid Tete Office No- A/201 Vithhal Complex, Above Sai Motors, Near selfe point Bhumkar Chauk, Narhe Pune -411058 Contact No: 8855032507 , 8855901508 Page 59SparkTech Consultancy Services (aren cy or ont ieey Above cat command is getting input from the file using std input operator ‘<’ Example:11 Sorting the output of multiple files into a single file cee ie te tem ee me ne ee By default sorting will done on the alphabetic order, if you want the sorting on basis of number then use ‘cnloption in the sort command. Example:15 View the Contents in Reverse Order tacis the reverse of cat command. tac will display the output in revers order example is shown below rie eed ee ao een Cee (root@linuxtechi “}# Office No- A/201 Vithhal Complex, Above Sai Motors, Near selfie point Bhumkar Chauk, Narhe Pune 411058 Contact No: 8855032507 , 8855901508 Page 60,SparkTech Consultancy Services 23. touch command The touch command is a standard command used in UNIX/Linux operating system which is used to create, change and modify timestamps of a file, Basically, there are two different commands to create a file in the Linux system which is as follows: cat command: Itis used to create the file with content, touch command: Its used to create a file without any content, The file created using touch command is empty. This command can be used when the user doesn’t have dats to store at the time of file creation Ising touch Command Initially, we are in home directory and this can be checked using the pwdcommand. Checking the existing files using command Is and then long listing commandill) is used to gather more details about existing files. As you can see in the below figure there is no existing files. Office No- A/201 Vithhal Compl ear selfie point Bhumkar Chauk, Narhe Pune ~411058 Contact No: 8855032507 , 8855901508 Page 61
You might also like
IT Recruiter's Mind-maps - Booklet
PDF
No ratings yet
IT Recruiter's Mind-maps - Booklet
25 pages
ZJC Computer Science Book 2 (New Curriculum)
PDF
0% (1)
ZJC Computer Science Book 2 (New Curriculum)
192 pages
Software Engineering For Internet Applications
PDF
No ratings yet
Software Engineering For Internet Applications
411 pages
1 Java Introduction
PDF
No ratings yet
1 Java Introduction
13 pages
Quiz Bab 4
PDF
No ratings yet
Quiz Bab 4
2 pages
Amazon SimpleDB Developer Guide 1st New edition Edition Prabhakar Chaganti - Read the ebook online or download it for a complete experience
PDF
No ratings yet
Amazon SimpleDB Developer Guide 1st New edition Edition Prabhakar Chaganti - Read the ebook online or download it for a complete experience
81 pages
Introduction To The Project
PDF
No ratings yet
Introduction To The Project
40 pages
Omkar.V.Choudhari Internship Report
PDF
No ratings yet
Omkar.V.Choudhari Internship Report
47 pages
Enterprise Application Development
PDF
No ratings yet
Enterprise Application Development
58 pages
Application Development
PDF
No ratings yet
Application Development
87 pages
1 Sri Krishna Adithya College of Arts and Science
PDF
No ratings yet
1 Sri Krishna Adithya College of Arts and Science
26 pages
15 MCA058 Shilpa
PDF
No ratings yet
15 MCA058 Shilpa
86 pages
Overview of Application Software
PDF
No ratings yet
Overview of Application Software
13 pages
Checkpoint-1 - 2167
PDF
No ratings yet
Checkpoint-1 - 2167
6 pages
15 MCA058 Shilpa
PDF
No ratings yet
15 MCA058 Shilpa
85 pages
Instant Access to Amazon SimpleDB Developer Guide 1st New edition Edition Prabhakar Chaganti ebook Full Chapters
PDF
No ratings yet
Instant Access to Amazon SimpleDB Developer Guide 1st New edition Edition Prabhakar Chaganti ebook Full Chapters
79 pages
MIS - Computer Software
PDF
No ratings yet
MIS - Computer Software
37 pages
Report 1
PDF
No ratings yet
Report 1
28 pages
Amazon SimpleDB Developer Guide 1st New edition Edition Prabhakar Chaganti download
PDF
No ratings yet
Amazon SimpleDB Developer Guide 1st New edition Edition Prabhakar Chaganti download
81 pages
Handbook For Technical Recruitment
PDF
No ratings yet
Handbook For Technical Recruitment
45 pages
Designing Enterprise Applications with the J2EE Platform 2nd Edition Inderjeet Singhpdf download
PDF
100% (2)
Designing Enterprise Applications with the J2EE Platform 2nd Edition Inderjeet Singhpdf download
53 pages
Designing Enterprise Applications with the J2EE Platform 2nd Edition Inderjeet Singh - The latest ebook version is now available for instant access
PDF
100% (1)
Designing Enterprise Applications with the J2EE Platform 2nd Edition Inderjeet Singh - The latest ebook version is now available for instant access
51 pages
Instant Download J2EE Developer s Handbook Paul J. Perrone PDF All Chapters
PDF
100% (2)
Instant Download J2EE Developer s Handbook Paul J. Perrone PDF All Chapters
81 pages
Hitch Hikers Guide Runtime Booklet
PDF
100% (2)
Hitch Hikers Guide Runtime Booklet
22 pages
Integrated Development Environment
PDF
No ratings yet
Integrated Development Environment
62 pages
E Advertisement Final
PDF
No ratings yet
E Advertisement Final
107 pages
Tech Concepts PM
PDF
No ratings yet
Tech Concepts PM
1 page
CH13 PowerPoint - Understanding Software
PDF
No ratings yet
CH13 PowerPoint - Understanding Software
38 pages
Backend
PDF
No ratings yet
Backend
68 pages
Install SW Application
PDF
No ratings yet
Install SW Application
37 pages
Get NET Wireless Programming 1st Edition Mark Ridgeway free all chapters
PDF
No ratings yet
Get NET Wireless Programming 1st Edition Mark Ridgeway free all chapters
67 pages
NET Wireless Programming 1st Edition Mark Ridgeway download
PDF
100% (1)
NET Wireless Programming 1st Edition Mark Ridgeway download
52 pages
题库
PDF
No ratings yet
题库
12 pages
GovExamDocCollege Report
PDF
No ratings yet
GovExamDocCollege Report
101 pages
Instant Access to Yii2 Application Development Cookbook 3rd Edition Alexander Makarov ebook Full Chapters
PDF
100% (8)
Instant Access to Yii2 Application Development Cookbook 3rd Edition Alexander Makarov ebook Full Chapters
60 pages
(Ebook) PHP Application Development with NetBeans by M A Hossain Tonu ISBN 9781849515801, 1849515808 instant download
PDF
100% (3)
(Ebook) PHP Application Development with NetBeans by M A Hossain Tonu ISBN 9781849515801, 1849515808 instant download
59 pages
KJSX
PDF
No ratings yet
KJSX
11 pages
Assignment
PDF
No ratings yet
Assignment
23 pages
Software
PDF
No ratings yet
Software
46 pages
Computer Software Class Notes
PDF
No ratings yet
Computer Software Class Notes
7 pages
Lecture 0 - Things You Need To Know (Version4)
PDF
No ratings yet
Lecture 0 - Things You Need To Know (Version4)
119 pages
Lesson 5 - System and Application Software
PDF
No ratings yet
Lesson 5 - System and Application Software
30 pages
Css Slem Format s2q1 Week 4
PDF
No ratings yet
Css Slem Format s2q1 Week 4
11 pages
Unit 7 Enterprise Application Architecture
PDF
No ratings yet
Unit 7 Enterprise Application Architecture
25 pages
Software Engineering
PDF
No ratings yet
Software Engineering
14 pages
Technology Resource - Software
PDF
No ratings yet
Technology Resource - Software
59 pages
Appdev Intro
PDF
No ratings yet
Appdev Intro
38 pages
Web Design & Development
PDF
No ratings yet
Web Design & Development
37 pages
Download full NET Wireless Programming 1st Edition Mark Ridgeway ebook all chapters
PDF
No ratings yet
Download full NET Wireless Programming 1st Edition Mark Ridgeway ebook all chapters
67 pages
Dharmsinh Desai University Faculty of Management and Information Science
PDF
No ratings yet
Dharmsinh Desai University Faculty of Management and Information Science
61 pages
CSC 307_SEN 305 MODULE 1 (1)
PDF
No ratings yet
CSC 307_SEN 305 MODULE 1 (1)
5 pages
Vansh Internship Report
PDF
No ratings yet
Vansh Internship Report
41 pages
Portfolio - PROGmaatic Developer Network
PDF
No ratings yet
Portfolio - PROGmaatic Developer Network
11 pages
Enterprise Computing Note
PDF
No ratings yet
Enterprise Computing Note
108 pages
Sierra Atlantic Software Services LTD: Date of Download
PDF
No ratings yet
Sierra Atlantic Software Services LTD: Date of Download
4 pages
Class0-July19
PDF
No ratings yet
Class0-July19
2 pages