{"id":1028,"date":"2017-12-21T02:44:36","date_gmt":"2017-12-21T02:44:36","guid":{"rendered":"http:\/\/blog.cloudxlab.com\/?p=1028"},"modified":"2017-12-22T04:35:27","modified_gmt":"2017-12-22T04:35:27","slug":"linux-tutorial-part-1","status":"publish","type":"post","link":"https:\/\/cloudxlab.com\/blog\/linux-tutorial-part-1\/","title":{"rendered":"A Simple Tutorial on Linux &#8211; Part-1"},"content":{"rendered":"<p>We have started this series of tutorials for Linux which is divided into two blog posts. Each one of them will cover basic concepts with practical examples. Also, we have provided the quiz on some of the topics that you can attend for free.<\/p>\n<p>In the first part of the series, we will learn the following topics in detail<\/p>\n<ul class=\"ili-indent\">\n<li>Linux Operating System<\/li>\n<li>Linux Files &amp; Process<\/li>\n<li>The Directory Structure<\/li>\n<li>Permissions<\/li>\n<li>Process<\/li>\n<\/ul>\n<h2>Introduction<\/h2>\n<p><span style=\"font-weight: 400;\">Linux is a Unix like operating system. It is open source and free. We might sometimes use the word &#8220;Unix&#8221; instead of Linux.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">A user can interact with Linux either using a &#8216;graphical interface&#8217; or using the &#8216;command line interface&#8217;.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Learning to use the command line interface has a bigger learning curve than the graphical interface but the former can be used to automate very easily. Also, most of the server side work is generally done using the command line interface.<\/span><\/p>\n<h2>Linux Operating System<\/h2>\n<p><span style=\"font-weight: 400;\">The operating system is made of three parts:<\/span><\/p>\n<h3 style=\"padding-left: 30px;\">1. The Programs<\/h3>\n<p style=\"padding-left: 30px;\"><span style=\"font-weight: 400;\">A user executes programs. AngryBird is a program that gets executed by the kernel, for example. When a program is launched, it creates processes. Program or process will be used interchangeably.<\/span><\/p>\n<h3 style=\"padding-left: 30px;\">2. The Kernel<\/h3>\n<p style=\"padding-left: 30px;\"><span style=\"font-weight: 400;\">The Kernel handles the main work of an operating system:<\/span><\/p>\n<ul class=\"ili-indent\">\n<li><span style=\"font-weight: 400;\">Allocates time &amp; memory to programs<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Handles File System<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Responds to various Calls<\/span><\/li>\n<\/ul>\n<h3 style=\"padding-left: 30px;\">3. The Shell<\/h3>\n<p style=\"padding-left: 30px;\"><span style=\"font-weight: 400;\">A user interacts with the Kernel via the Shell. The console as opened in the previous slide is the shell. A user writes instructions in the shell to execute commands. Shell is also a program that keeps asking you to type the name of other programs to run.<\/span><\/p>\n<p><!--more--><\/p>\n<h2>Linux Files &amp; Processes<\/h2>\n<p><span style=\"font-weight: 400;\">Everything in Unix is either a file or a process.<\/span><\/p>\n<h3>Process<\/h3>\n<p><span style=\"font-weight: 400;\">When you run a program, a process is created. Every process is identified by a number called process ID. To check the processes you are running, execute &#8220;ps&#8221; command on the shell. You can think of the process ID to be a sequence number given by the operating system. It may be different at a different execution of the same program.<\/span><\/p>\n<h3>File<\/h3>\n<p><span style=\"font-weight: 400;\">A file is a sequence of data. A file could be created by users using word processors or text editors or by the program to keep the information. A program is kept in the form of a file and when it is run by the kernel, it loads as a process.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">A file is generally written on the disk so that it exists even after the computer restarts. It is saved in a disk &#8211; either hard disk drive (HDD &#8211; cheaper and slower) or solid state drive (SSD &#8211; faster but costlier).<\/span><\/p>\n<p><span style=\"font-weight: 400;\">A file is identified by a name called file path. In Unix, everything is represented as file:<\/span><\/p>\n<ol class=\"ili-indent\">\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Devices such as Mouse, Keyboard<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Programs are saved as file<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Disk and Monitor<\/span><\/li>\n<\/ol>\n<p><a href=\"https:\/\/cloudxlab.com\/assessment\/slide\/linux-basics\/11\/number-of-processes?course_id=2\" target=\"_blank\" rel=\"noopener\">Attend the quiz on Process<\/a><\/p>\n<h2>The Directory Structure<\/h2>\n<p><span style=\"font-weight: 400;\">A file is kept inside a directory. A directory can have a file or another directory inside it. It is like an inverted tree.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The top-level directory is &#8220;\/&#8221; called root. &#8220;\/&#8221; directory does not have a parent. \/A\/B means B is inside A which is inside top-level directory &#8220;root&#8221;.<\/span><\/p>\n<p><img class=\"aligncenter size-full wp-image-1056\" src=\"http:\/\/blog.cloudxlab.com\/wp-content\/uploads\/2017\/12\/filesystem.png\" alt=\"\" width=\"306\" height=\"447\" srcset=\"https:\/\/cloudxlab.com\/blog\/wp-content\/uploads\/2017\/12\/filesystem.png 306w, https:\/\/cloudxlab.com\/blog\/wp-content\/uploads\/2017\/12\/filesystem-205x300.png 205w\" sizes=\"(max-width: 306px) 85vw, 306px\" \/><\/p>\n<h3>List Files and Directory<\/h3>\n<p><span style=\"font-weight: 400;\">To see the list of files use the command:<\/span><\/p>\n<pre class=\"lang:default decode:true\">ls<\/pre>\n<h3>Relative &amp; Absolute Paths &#8211; Change the Directory<\/h3>\n<p><span style=\"font-weight: 400;\">There are two ways to represent a file\/directory path:<\/span><\/p>\n<h5 style=\"padding-left: 30px;\"><b>1. Absolute<\/b><\/h5>\n<p style=\"padding-left: 30px;\"><span style=\"font-weight: 400;\">This way of representing a file\/directory is independent of current directory of the user. Such paths start with &#8220;\/&#8221;. Examples: \/etc\/passwd.<\/span><\/p>\n<h5 style=\"padding-left: 30px;\"><b>2. Relative<\/b><\/h5>\n<p style=\"padding-left: 30px;\"><span style=\"font-weight: 400;\">Relative to the current working directory. Examples: ..\/..\/etc\/passwd<\/span><\/p>\n<p style=\"padding-left: 30px;\"><span style=\"font-weight: 400;\">You can change directory using &#8220;cd&#8221; command. Every user is given a separate home directory.<\/span><\/p>\n<h3>Home Directory &amp; Current Directory<\/h3>\n<p><span style=\"font-weight: 400;\">Inside the console, you are always in the directory. On login, by default, you land in your home directory.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">To see the present working directory use: <\/span><strong>pwd<\/strong><\/p>\n<p><span style=\"font-weight: 400;\">To change the directory to your home directory use only &#8220;<\/span><span style=\"font-weight: 400;\"><strong>cd<\/strong>&#8220;<\/span><span style=\"font-weight: 400;\"> command without any arguments.<\/span><\/p>\n<p><a href=\"https:\/\/cloudxlab.com\/assessment\/slide\/linux-basics\/13\/relative-file-names\" target=\"_blank\" rel=\"noopener\">Attend the quiz on directory<\/a><\/p>\n<h3>Create Directory<\/h3>\n<p>You can create a\u00a0directory using <strong>mkdir<\/strong> command in the following way:<\/p>\n<pre class=\"lang:default decode:true\">mkdir directoryname<\/pre>\n<h3>Delete a file<\/h3>\n<p>To delete a file you can use &#8216;<strong>rm<\/strong>&#8216; command. To delete the directory you have to have &#8220;<strong>-r<\/strong>&#8221; switch with rm command.<\/p>\n<pre class=\"lang:default decode:true\">rm -r directoryname<\/pre>\n<h3>Create File<\/h3>\n<p>A file is a sequence of bytes and represents data. It is found in a directory. A file could contain any kind of data: an executable program, data representing movies, music, pictures or plain text.<\/p>\n<p>You can create an empty file using the <strong>touch<\/strong> command. Please note that the extension of the file doesn&#8217;t matter much in Unix.<\/p>\n<pre class=\"lang:default decode:true \">touch myemptyfile.txt<\/pre>\n<h3>Create Text File Using Nano<\/h3>\n<p>You can use a text editor to edit or create a text file. There are many editors in Linux such as nano, pico, vi, emacs. Let&#8217;s try to use nano for creating a file<\/p>\n<p>1. Launch nano to edit:<\/p>\n<pre class=\"lang:default decode:true \">nano myfirstfile.txt<\/pre>\n<p>2. Type the following text into it:<\/p>\n<pre class=\"lang:default decode:true \">He walked into his exile<\/pre>\n<p>3. Press &#8220;Control+x&#8221; to save and then confirm by typing y<\/p>\n<h3>Copy File<\/h3>\n<p>To copy files and directories we use the <strong>cp<\/strong> command. Following is the way to make a copy of a file.<\/p>\n<pre class=\"lang:default decode:true \">cp myfirstfile.txt myfirstfile_copy.txt<\/pre>\n<h3>Move Files &amp; Directories<\/h3>\n<p><strong>mv<\/strong> command is used to move or rename files and directories.<\/p>\n<p>rename myfirstfile.txt to firstfile.txt<\/p>\n<pre class=\"lang:default decode:true\">mv myfirstfile.txt firstfile.txt<\/pre>\n<h3>Seeing inside\u00a0the File &#8211; cat, tail, head<\/h3>\n<p><span style=\"font-weight: 400;\">To see what is inside a text file, you can use either <strong>cat, tail, or head<\/strong>.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Using <strong>cat<\/strong> you can see the whole content of the file:<\/span><\/p>\n<pre class=\"lang:default decode:true\">cat myfirstfile_copy.txt<\/pre>\n<p><span style=\"font-weight: 400;\">Do not use this command to look inside a huge file. For the huge file, you can use the &#8220;more&#8221; command which would display the content of a file in a paginated way:<\/span><\/p>\n<pre class=\"lang:default decode:true\">more myfirstfile_copy.txt<\/pre>\n<p><span style=\"font-weight: 400;\"><strong>tail<\/strong> shows you the last few lines of a file<\/span><\/p>\n<pre class=\"lang:default decode:true\">tail myfirstfile_copy.txt<\/pre>\n<p><span style=\"font-weight: 400;\">By default tail shows you only last 10 lines, you can change it using command line option. For example, to see last 20 lines, you can use<\/span><\/p>\n<pre class=\"lang:default decode:true\">tail -20 myfirstfile_copy.txt<\/pre>\n<p><span style=\"font-weight: 400;\">If you want to chase a file &#8211; continuously print newlines appended to the file &#8211; use the following command:<\/span><\/p>\n<pre class=\"lang:default decode:true\">tail -f myfirstfile_copy.txt<\/pre>\n<p><span style=\"font-weight: 400;\">If you are interested in the first few lines, you can use head.\u00a0 By default <strong>head<\/strong> shows you only first 10 lines, you can change it using command line option. For example, to see first 20 lines, you can use<\/span><\/p>\n<pre class=\"lang:default decode:true\">head -20 myfirstfile_copy.txt<\/pre>\n<p><a href=\"https:\/\/cloudxlab.com\/assessment\/slide\/linux-basics\/28\/commands\" target=\"_blank\" rel=\"noopener\">Attend the quiz on commands<\/a><\/p>\n<h3>Use find command<\/h3>\n<p><span style=\"font-weight: 400;\">Sometimes you might want to search for a particular file based on various attributes of a file such as size or name etc. The find command comes in very handy for such use cases.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">For example, to find all the text files in current directory, you can use this command<\/span><\/p>\n<pre class=\"lang:default decode:true\">find . -name '*.txt'<\/pre>\n<h3>Use grep command<\/h3>\n<p><span style=\"font-weight: 400;\">If you want to locate a word in files, you can use the <strong>grep<\/strong> command. Grep lists all the lines from files in which a particular word exists. Examples of grep<\/span><\/p>\n<pre class=\"lang:default decode:true \">grep myword file1 file2<\/pre>\n<p><span style=\"font-weight: 400;\">If you want to search in files recursively &#8211; inside every subdirectory of a directory, use the following command<\/span><\/p>\n<pre class=\"lang:default decode:true \">grep -r myword directory<\/pre>\n<p><span style=\"font-weight: 400;\">If you want to search case insensitive, use &#8220;-i&#8221; switch<\/span><\/p>\n<pre class=\"lang:default decode:true\">grep -i myword file1 file2\r\n<\/pre>\n<h5><strong>Practical Use Cases<\/strong><\/h5>\n<p><span style=\"font-weight: 400;\">grep is a very powerful tool. It can somewhat behave like where clause in sql queries.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Few Examples are:<\/span><\/p>\n<ol class=\"ili-indent\">\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">On a web server you could filter only the errors from a log file<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Say you have a directory containing the temperature of various cities and you are looking for temperatures of the city having name as nyc, you could easily do: grep nyx tempdirectory\/*<\/span><\/li>\n<\/ol>\n<h3>Use wc command<\/h3>\n<p><span style=\"font-weight: 400;\">To find the number of characters, words, and lines, use the <strong>wc<\/strong> command.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">If you are only looking for the number of lines you could use:<\/span><\/p>\n<pre class=\"lang:default decode:true \">wc -l<\/pre>\n<p><a href=\"https:\/\/cloudxlab.com\/assessment\/slide\/linux-basics\/36\/check-number-of-characters-in-a-file\" target=\"_blank\" rel=\"noopener\">Attend the quiz on wc command<\/a><\/p>\n<h2>Permissions &#8211; Overview<\/h2>\n<p><span style=\"font-weight: 400;\">Permissions in unix are integral part of the operating system.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">You can see the details of a file using ls -la command:<\/span><\/p>\n<pre class=\"lang:default decode:true\">ls -la myfile<\/pre>\n<p><span style=\"font-weight: 400;\">And you can see the details of all files in the current directory by using:<\/span><\/p>\n<pre class=\"lang:default decode:true \">ls -la<\/pre>\n<p><span style=\"font-weight: 400;\">Every file has an owner (also referred as a user), a group and permissions. A user can be part of many groups. A group can have many users.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The permission attributes of a file signify who can do what.<\/span><\/p>\n<p>&nbsp;<\/p>\n<h3>Using chmod To Change<\/h3>\n<p><span style=\"font-weight: 400;\">You can change the permissions of a file using chmod command: chmod permission_cmd myfile<\/span><\/p>\n<p><span style=\"font-weight: 400;\">You can allow or disallow the user (u), group (g) or other(o) the following actions: read (r), write (w) and execute (x).<\/span><\/p>\n<p><span style=\"font-weight: 400;\">So, if you want to allow the user (the person who owns it) to execute the file:<\/span><\/p>\n<pre class=\"lang:default decode:true\">chmod u+x myfile<\/pre>\n<p><span style=\"font-weight: 400;\">And to disallow the user (the person who owns it) to execute the file:<\/span><\/p>\n<pre class=\"lang:default decode:true \">chmod u-x myfile<\/pre>\n<p><span style=\"font-weight: 400;\">Say you want to give the rw permissions to owner and group of a file, you will have to use the following command:<\/span><\/p>\n<pre class=\"lang:default decode:true \">chmod u+r,u+w,g+r,g+w myfile<\/pre>\n<p><span style=\"font-weight: 400;\">or<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><\/p>\n<pre class=\"lang:default decode:true\">chmod u+rw,g+rw myfile<\/pre>\n<p><span style=\"font-weight: 400;\">To give members of a group ability to modify a file, use:<\/span><\/p>\n<pre class=\"lang:default decode:true \">chmod g+w myfile\r\n\r\n<\/pre>\n<h3>Assignment &#8211; Owner can change, others can only read<\/h3>\n<p><span style=\"font-weight: 400;\">Create a new file called myemptyfile. You can use:<\/span><\/p>\n<pre class=\"lang:default decode:true\">touch myemptyfile<\/pre>\n<p><span style=\"font-weight: 400;\">Check its permissions using:<\/span><\/p>\n<pre class=\"lang:default decode:true\">ls -l myemptyfile<\/pre>\n<p><span style=\"font-weight: 400;\">Using <strong>chmod<\/strong>, give it permissions such that owner of a file should be able to modify. Everyone else should be able to only read.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Hint: You can use the following command to remove the write permissions from group and others:<\/span><\/p>\n<pre class=\"lang:default decode:true \">chmod o-w,g-w myemptyfile<\/pre>\n<h3>Assignment &#8211; Everyone can execute<\/h3>\n<p><span style=\"font-weight: 400;\">Create a new file called myemptyfile. You can use:<\/span><\/p>\n<pre class=\"lang:default decode:true \">touch myemptyfile<\/pre>\n<p><span style=\"font-weight: 400;\">Check its permissions using:<\/span><\/p>\n<pre class=\"lang:default decode:true \">ls -l myemptyfile<\/pre>\n<p><span style=\"font-weight: 400;\">Using <strong>chmod<\/strong>, give it permissions such that the owner of a file should be able to modify. Everyone should be able to execute but no one can modify the file.<\/span><\/p>\n<h3>Assignment &#8211; Nobody other than owner can read the file<\/h3>\n<p><span style=\"font-weight: 400;\">Create a new file called myemptyfile. You can use:<\/span><\/p>\n<pre class=\"lang:default decode:true\">touch myemptyfile<\/pre>\n<p><span style=\"font-weight: 400;\">Check its permissions using:<\/span><\/p>\n<pre class=\"lang:default decode:true \">ls myemptyfile<\/pre>\n<p><span style=\"font-weight: 400;\">Using <strong>chmod<\/strong>, give it permissions such that nobody other than the owner of a file can read the file.<\/span><\/p>\n<h3>Assignment &#8211; Only Group Members can read<\/h3>\n<p><span style=\"font-weight: 400;\">Create a new file called myemptyfile. You can use:<\/span><\/p>\n<pre class=\"lang:default decode:true\">touch myemptyfile<\/pre>\n<p><span style=\"font-weight: 400;\">Check its permissions using:<\/span><\/p>\n<pre class=\"lang:default decode:true\">ls myemptyfile<\/pre>\n<p><span style=\"font-weight: 400;\">Using <strong>chmod<\/strong>, give it permissions such that owner of a file should be able to read and modify, members of groups can only read, others can&#8217;t read or modify.<\/span><\/p>\n<h3>Permissions &#8211; Numeric<\/h3>\n<p><span style=\"font-weight: 400;\">You can also use numbers to represent the permissions.<\/span><\/p>\n<p><img class=\"aligncenter size-full wp-image-1061\" src=\"http:\/\/blog.cloudxlab.com\/wp-content\/uploads\/2017\/12\/permissions.png\" alt=\"\" width=\"402\" height=\"337\" srcset=\"https:\/\/cloudxlab.com\/blog\/wp-content\/uploads\/2017\/12\/permissions.png 402w, https:\/\/cloudxlab.com\/blog\/wp-content\/uploads\/2017\/12\/permissions-300x251.png 300w\" sizes=\"(max-width: 402px) 85vw, 402px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">So, for a file with permissions rwxr-xr-x, the owner has rwx permission which 4+2+1=7 and group and others have r-x which means 4+0+1 = 5. Thus the command you would use to set such permission would be: chmod 755 myfile.<\/span><\/p>\n<p><a href=\"https:\/\/cloudxlab.com\/assessment\/slide\/linux-basics\/65\/permissions-numeric-representation\" target=\"_blank\" rel=\"noopener\">Attend the quiz on permission &#8211; numeric<\/a><\/p>\n<h3>Permissions &#8211; Advanced<\/h3>\n<p><span style=\"font-weight: 400;\">There is a special user called root on Unix systems which has all the privileges which can give permission to any user on any file.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Some users who are allowed to act on behalf of the root are called sudoers. This list of sudoers can be edited using the <strong>sudoedit<\/strong> command. Such users are allowed to run commands as if they are root using: sudo .<\/span><\/p>\n<p><span style=\"font-weight: 400;\">You can change the owner of a file using <strong>chown<\/strong> and change the group of a file using the <strong>chgrp<\/strong> command. Please note that changing the owner of the file is possible only with the administrative account.<\/span><\/p>\n<p><a href=\"https:\/\/cloudxlab.com\/assessment\/slide\/linux-basics\/62\/who-can-delete-a-file\" target=\"_blank\" rel=\"noopener\">Attend the quiz on permissions &#8211; advanced<\/a><\/p>\n<h2>Process<\/h2>\n<p><span style=\"font-weight: 400;\">Every program or command is a sequence of instructions stored as a file. You run it on the shell or by any other means such as double-clicking it from the user interface. <\/span><\/p>\n<p><span style=\"font-weight: 400;\">When it is run, the content of the program is read from a file and loaded into the memory and then instructions are executed by the operating system. <\/span><\/p>\n<p><span style=\"font-weight: 400;\">All the commands that we have been using ls, cat were programs.<\/span><\/p>\n<p><a href=\"https:\/\/cloudxlab.com\/assessment\/slide\/linux-basics\/41\/which-one-is-a-process\" target=\"_blank\" rel=\"noopener\">Attend the quiz on process<\/a><\/p>\n<h3>Find information about processes<\/h3>\n<p><span style=\"font-weight: 400;\">While a program is running, it is called a process. A process is uniquely identified by PID &#8211; process id. To find out the information about all the processes, you can use the following commands: <strong>pstree, top, ps<\/strong>.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">ps lists the processes of the system. Without any arguments, it lists only your processes. To see all of the processes by all users, run<\/span><\/p>\n<pre class=\"lang:default decode:true \">ps aux<\/pre>\n<p><span style=\"font-weight: 400;\">The first column mentions the user id who has started the process.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">To continuously monitor all processes, use &#8220;<strong>top<\/strong>&#8221; command. This command is usually used to monitor which processes are running, taking up most CPU or Memory.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">To learn more about command use man command name. So, please go through manual using command<\/span><\/p>\n<pre class=\"lang:default decode:true\">man ps\r\n\r\nman top<\/pre>\n<h3>Background Processes<\/h3>\n<p><span style=\"font-weight: 400;\">So far whenever we ran a command, if it is taking time, we had to wait till it finishes before we could type another command. If a process is taking time and does not require input from you, you would like to run it in the background.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">To run a program in the background, put a &#8216;&amp;&#8217; at the end of the command:<\/span><\/p>\n<pre class=\"lang:default decode:true \">mycmd &amp;<\/pre>\n<h3>Send a process in background<\/h3>\n<p><span style=\"font-weight: 400;\">There is a command called sleep which can make you wait for specified seconds. Please send sleep command in background using:<\/span><\/p>\n<pre class=\"lang:default decode:true \">\u00a0\u00a0sleep 1000 &amp;<\/pre>\n<p><span style=\"font-weight: 400;\">To kill any running process, please use the command:<\/span><\/p>\n<pre class=\"lang:default decode:true\">kill processid<\/pre>\n<p><span style=\"font-weight: 400;\">Basically, &#8220;kill&#8221; lets you send a signal to the running process. For example, to send terminate signal, you can use<\/span><\/p>\n<pre class=\"lang:default decode:true\">kill -9 processid<\/pre>\n<h3>More &#8211; Interacting with processes<\/h3>\n<p><span style=\"font-weight: 400;\">To send a running process to background, first press &#8216;Ctrl+z&#8217; to suspend it and then type <\/span><i><span style=\"font-weight: 400;\">bg<\/span><\/i><span style=\"font-weight: 400;\"> to send the suspended process to background.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">When you exit the shell or disconnect, the processes you were running get killed. To keep a process running in the background even if the shell has been disconnected, use<\/span><\/p>\n<pre class=\"lang:default decode:true \">nohup<\/pre>\n<p><span style=\"font-weight: 400;\">or<\/span><\/p>\n<pre class=\"lang:default decode:true\">screen<\/pre>\n<h3>Process hierarchy<\/h3>\n<p><span style=\"font-weight: 400;\">A process (parent) can execute another process (child). When a parent process is killed all the child processes are automatically killed. The main system process that is started first is numbered as 1. If this process is killed the system will shut down.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">To see the tree of processes, you can use the command<\/span><\/p>\n<pre class=\"lang:default decode:true\">pstree<\/pre>\n<p><span style=\"font-weight: 400;\">A user can kill only the processes that the user has executed not the processes of other users. Only root can kill the processes of other users.<\/span><\/p>\n<p><a href=\"https:\/\/cloudxlab.com\/assessment\/slide\/linux-basics\/51\/command-to-kill-a-process\" target=\"_blank\" rel=\"noopener\">Attend the quiz on process hierarchy<\/a><\/p>\n<p>In the second part of the Linux series, we will learn how to write a shell script followed by other important concepts and commands.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We have started this series of tutorials for Linux which is divided into two blog posts. Each one of them will cover basic concepts with practical examples. Also, we have provided the quiz on some of the topics that you can attend for free. In the first part of the series, we will learn the &hellip; <a href=\"https:\/\/cloudxlab.com\/blog\/linux-tutorial-part-1\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;A Simple Tutorial on Linux &#8211; Part-1&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":1065,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[14],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v16.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>A Simple Tutorial on Linux - Part-1 | CloudxLab Blog<\/title>\n<meta name=\"description\" content=\"Linux is easy to learn and this post gives the introduction to Linux environment with very useful concepts and commands with practical examples.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cloudxlab.com\/blog\/linux-tutorial-part-1\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"A Simple Tutorial on Linux - Part-1 | CloudxLab Blog\" \/>\n<meta property=\"og:description\" content=\"Linux is easy to learn and this post gives the introduction to Linux environment with very useful concepts and commands with practical examples.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cloudxlab.com\/blog\/linux-tutorial-part-1\/\" \/>\n<meta property=\"og:site_name\" content=\"CloudxLab Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/cloudxlab\" \/>\n<meta property=\"article:published_time\" content=\"2017-12-21T02:44:36+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-12-22T04:35:27+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cloudxlab.com\/blog\/wp-content\/uploads\/2017\/12\/learn-linux-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1024\" \/>\n\t<meta property=\"og:image:height\" content=\"512\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@CloudxLab\" \/>\n<meta name=\"twitter:site\" content=\"@CloudxLab\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\">\n\t<meta name=\"twitter:data1\" content=\"12 minutes\">\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/cloudxlab.com\/blog\/#website\",\"url\":\"https:\/\/cloudxlab.com\/blog\/\",\"name\":\"CloudxLab Blog\",\"description\":\"Learn AI, Machine Learning, Deep Learning, Devops &amp; Big Data\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/cloudxlab.com\/blog\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/cloudxlab.com\/blog\/linux-tutorial-part-1\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/cloudxlab.com\/blog\/wp-content\/uploads\/2017\/12\/learn-linux-1.png\",\"contentUrl\":\"https:\/\/cloudxlab.com\/blog\/wp-content\/uploads\/2017\/12\/learn-linux-1.png\",\"width\":1024,\"height\":512,\"caption\":\"Learn Linux\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cloudxlab.com\/blog\/linux-tutorial-part-1\/#webpage\",\"url\":\"https:\/\/cloudxlab.com\/blog\/linux-tutorial-part-1\/\",\"name\":\"A Simple Tutorial on Linux - Part-1 | CloudxLab Blog\",\"isPartOf\":{\"@id\":\"https:\/\/cloudxlab.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/cloudxlab.com\/blog\/linux-tutorial-part-1\/#primaryimage\"},\"datePublished\":\"2017-12-21T02:44:36+00:00\",\"dateModified\":\"2017-12-22T04:35:27+00:00\",\"author\":{\"@id\":\"https:\/\/cloudxlab.com\/blog\/#\/schema\/person\/0efa3c54df68406de820ea466f002d3c\"},\"description\":\"Linux is easy to learn and this post gives the introduction to Linux environment with very useful concepts and commands with practical examples.\",\"breadcrumb\":{\"@id\":\"https:\/\/cloudxlab.com\/blog\/linux-tutorial-part-1\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cloudxlab.com\/blog\/linux-tutorial-part-1\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cloudxlab.com\/blog\/linux-tutorial-part-1\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cloudxlab.com\/blog\/\",\"url\":\"https:\/\/cloudxlab.com\/blog\/\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"position\":2,\"item\":{\"@id\":\"https:\/\/cloudxlab.com\/blog\/linux-tutorial-part-1\/#webpage\"}}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/cloudxlab.com\/blog\/#\/schema\/person\/0efa3c54df68406de820ea466f002d3c\",\"name\":\"Abhinav Singh\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/cloudxlab.com\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/fc74fe31169bf872f6ab11bbab621d53?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/fc74fe31169bf872f6ab11bbab621d53?s=96&d=mm&r=g\",\"caption\":\"Abhinav Singh\"},\"sameAs\":[\"https:\/\/cloudxlab.com\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/cloudxlab.com\/blog\/wp-json\/wp\/v2\/posts\/1028"}],"collection":[{"href":"https:\/\/cloudxlab.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cloudxlab.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cloudxlab.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudxlab.com\/blog\/wp-json\/wp\/v2\/comments?post=1028"}],"version-history":[{"count":13,"href":"https:\/\/cloudxlab.com\/blog\/wp-json\/wp\/v2\/posts\/1028\/revisions"}],"predecessor-version":[{"id":1080,"href":"https:\/\/cloudxlab.com\/blog\/wp-json\/wp\/v2\/posts\/1028\/revisions\/1080"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cloudxlab.com\/blog\/wp-json\/wp\/v2\/media\/1065"}],"wp:attachment":[{"href":"https:\/\/cloudxlab.com\/blog\/wp-json\/wp\/v2\/media?parent=1028"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cloudxlab.com\/blog\/wp-json\/wp\/v2\/categories?post=1028"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cloudxlab.com\/blog\/wp-json\/wp\/v2\/tags?post=1028"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}