<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Commands Archives - Linuxcent</title>
	<atom:link href="https://linuxcent.com/category/commands/feed/" rel="self" type="application/rss+xml" />
	<link>https://linuxcent.com/category/commands/</link>
	<description>Infrastructure security, from the kernel up.</description>
	<lastBuildDate>Wed, 08 Mar 2023 05:14:34 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.4</generator>

<image>
	<url>https://linuxcent.com/wp-content/uploads/2026/04/favicon-512x512-1-150x150.png</url>
	<title>Commands Archives - Linuxcent</title>
	<link>https://linuxcent.com/category/commands/</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">211632295</site>	<item>
		<title>How to Shutdown or Reboot a remote Linux Host from commandline</title>
		<link>https://linuxcent.com/how-to-shutdown-or-reboot-a-remote-linux-host-from-commandline/</link>
					<comments>https://linuxcent.com/how-to-shutdown-or-reboot-a-remote-linux-host-from-commandline/#respond</comments>
		
		<dc:creator><![CDATA[Vamshi Krishna Santhapuri]]></dc:creator>
		<pubDate>Wed, 08 Mar 2023 04:24:00 +0000</pubDate>
				<category><![CDATA[Commands]]></category>
		<category><![CDATA[Linux Tutorials]]></category>
		<guid isPermaLink="false">https://linuxcent.com/?p=102</guid>

					<description><![CDATA[<p><span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> 6</span> <span class="rt-label rt-postfix">minutes</span></span>The Shutdown process in a Linux system is an intelligent chain process where in the system ensures the dependent process have successfully terminated. TL;DR: Difference between the Halt and Poweroff in Linux? What is a Cold Shutdown and Warm Shutdown? Linux System : The Halt process instructs the hardware to Stop the functioning of the ... <a title="How to Shutdown or Reboot a remote Linux Host from commandline" class="read-more" href="https://linuxcent.com/how-to-shutdown-or-reboot-a-remote-linux-host-from-commandline/" aria-label="Read more about How to Shutdown or Reboot a remote Linux Host from commandline">Read more</a></p>
<p>The post <a href="https://linuxcent.com/how-to-shutdown-or-reboot-a-remote-linux-host-from-commandline/">How to Shutdown or Reboot a remote Linux Host from commandline</a> appeared first on <a href="https://linuxcent.com">Linuxcent</a>.</p>
]]></description>
										<content:encoded><![CDATA[<span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> 6</span> <span class="rt-label rt-postfix">minutes</span></span><p>The Shutdown process in a Linux system is an intelligent chain process where in the system ensures the dependent process have successfully terminated.</p>
<h2>TL;DR:</h2>
<p>Difference between the Halt and Poweroff in Linux?<br />
What is a Cold Shutdown and Warm Shutdown?<br />
Linux System <code>System Halt </code>: The Halt process instructs the hardware to Stop the functioning of the CPU. Can be referred as a Warm Shutdown.<br />
Linux System <code>Poweroff/Shutdown </code>: The Poweroff function sends the ACPI(Advanced Configuration and Power Interface) to power down the system. Can be referred as a Cold Shutdown.</p>
<p>As you may be aware the Linux runtime environment is a duo combination of processes running in User space and the Kernel space, All the major system activities and resources are initiated and governed and terminated by Kernel space.<br />
So we got the Kernel space and the User space, The kernel space is where all the reseurce related processes run, which follows a finite behaviour, and the the userspace where the processes are dependent on the user actions, most of the userspace programs depend on the kernel space and make a context switch to get the CPU scheduling and such..<br />
So, In the sequence of Shutdown on a linux machine, the userspace processes are first terminated in a systematic fashion through the scripts triggered by the core systemd processes which ensures clean exit and termination all the processes.</p>
<p>The Linux system provides us quite a few commands to enforce fast shutdown or a graceful shutdown of the operating system, each having their own consequences.</p>
<p>Firstly the <code>init</code> or the <code>systemd</code> which is the <code>pid 1</code> process is what controls the runlevel of the system and it determines which processes are launched and running in that runlevel</p>
<p>The <code>init</code> is a powerful command which executes the runlevel it is told to.<br />
Here the <code>init 0</code> proceeds to Power-off the machine</p>
<pre>$ sudo init 0</pre>
<p>Here the <code>init 6</code> proceeds to Reboot the machine</p>
<pre>$ sudo init 6</pre>
<p>These commands are real quick as it triggers the kernel space shutdown invocation process.. most often resulting in unclean termination of processes resulting system recovery and journaling while booting.</p>
<p>The following commands Shutdown the machine in seconds after issuing the command But tend to follow the kill sequence and clean exit of the processed.</p>
<pre>$ sudo shutdown
$ sudo poweroff
$ sudo systemctl poweroff</pre>
<p>Prints a wall message to all users.<br />
All the processes are killed and the volumes are unmounted or converted to be in Read-Only mode while system power off is in progress.<br />
Puts the system into a complete poweroff mode cutting out power supply to the machine completely.</p>
<pre>$ sudo halt
$ sudo systemctl halt</pre>
<p>Prints a message of &#8220;System halted&#8221; and Puts the machine in halt mode<br />
If the <code>--force</code> or <code>-f</code> when specified twice the operation is immediately executed without terminating any processes or unmounting any file systems and resulting in data loss</p>
<p>The servers can only be brought back online through physical poweron or Remote Power manager console such as IPMI or ILOM.</p>
<p>To reboot or [/code]systemctl kexec[/code] will to restart the operating system which is one power cycle or equivalent of shutdown followed by the startup.</p>
<pre>$ sudo reboot

$ sudo systemctl kexec

$ sudo systemctl reboot</pre>
<p>If the <code>--force</code> or <code>-f</code> when specified twice the operation is immediately executed without terminating any processes or unmounting any file systems and resulting in data loss</p>
<p>&nbsp;</p>
<p>It is important to understand that the commands are all softlinks to systemctl shutdown command. and ensure in proper shutdown sequence process</p>
<pre>[vamshi@linuxcent cp-command]$ ls -l /usr/sbin/halt
lrwxrwxrwx. 1 root root 16 Jan 13 14:41 /usr/sbin/halt -&gt; ../bin/systemctl
[vamshi@linuxcent cp-command]$ ls -l /usr/sbin/reboot
lrwxrwxrwx. 1 root root 16 Jan 13 14:41 /usr/sbin/reboot -&gt; ../bin/systemctl
[vamshi@linuxcent cp-command]$ ls -l /usr/sbin/poweroff
lrwxrwxrwx. 1 root root 16 Jan 13 14:41 /usr/sbin/poweroff -&gt; ../bin/systemctl</pre>
<p>It is important to observe that all the commands are softlink to the systemctl process, When issuing a shutdown or reboot</p>
<p>The best practice to poweroff the system by enabling broadcast the notification message to all the users connected actively either through the Pseudo remote connection terminal or TTY terminals, Demonstrated as follows:</p>
<pre>$ sudo systemctl poweroff</pre>
<p># this writes an entry into the journal, the wtmp and broadcasts the shutdown message to all the users connected through PTS and TTY terminals</p>
<h2>What is the difference between systemctl poweroff and systemctl halt ?</h2>
<p>The Linux System when put to a Halt state, stops the all the applications and ensures they&#8217;re safely exited, filesystems and volumes are unmounted and it is taken into a halted state where in the power connection is still active. And Can only be brought  online with a power reset effectively with a simple reset.<br />
The <code>Halt</code> process instructs the hardware to Stop the functioning of the CPU.<br />
Commonly can be referred as a <code>Warm Shutdown</code>.</p>
<p>Below is the screenshot to demonstrate the same<br />
<img fetchpriority="high" decoding="async" class="alignnone wp-image-271 size-full" src="https://linuxcent.com/wp-content/uploads/2020/04/systemctl-halt-command.png" alt="systemctl halt command in linux" width="716" height="389" srcset="https://linuxcent.com/wp-content/uploads/2020/04/systemctl-halt-command.png 716w, https://linuxcent.com/wp-content/uploads/2020/04/systemctl-halt-command-300x163.png 300w" sizes="(max-width: 716px) 100vw, 716px" /></p>
<p>The <code>Poweroff</code> function sends the <code>ACPI</code>(Advanced Configuration and Power Interface) to power down the system.<br />
The Linux System when put to a Poweroff state it becomes completely offline following the systematical clean termination of processes.. and power input is cut off to the external peripherals, which is also sometimes called as cold shutdown, and the startup cold start.<br />
Commonly can be referred to as a <code>Cold Shutdown</code>.</p>
<p>If you found the article worth your time, Please share your inputs in the comments section and share your experiences with shutdown and reboot issues</p>
<h2>Can I reboot Linux remotely?</h2>
<p>How to shutdown the remote Linux server. You must pass the -t option to the ssh command to force pseudo-terminal allocation. The shutdown accepts -h option i.e. Linux is powered/halted at the specified time.</p>
<h2>Can you reboot a server remotely?</h2>
<p>Open command prompt, and type “shutdown /m \\RemoteServerName /r /c “Comments”“. &#8230; Another command to restart or shutdown the Server remotely is Shutdown /i. Type Shutdown /i on the command prompt and it will open another dialogue box.</p>
<h2>What is the Linux command to reboot?</h2>
<p>To reboot Linux using the command line:</p>
<ol>
<li>To reboot the Linux system from a terminal session, sign in or “su”/”sudo” to the “root” account.</li>
<li>Then type “ sudo reboot ” to reboot the box.</li>
<li>Wait for some time and the Linux server will reboot itself.</li>
</ol>
<h2>How do I reboot from remote desktop?</h2>
<p>Procedure. Use the Restart Desktop command. Select Options &gt; Restart Desktop from the menu bar. Right-click the remote desktop icon and select Restart Desktop.</p>
<h2>What does sudo reboot do?</h2>
<p>sudo is short for &#8220;Super-user Do&#8221;. It has no effect on the command itself (this being reboot ), it merely causes it to run as the super-user rather than as you. It is used to do things that you might not otherwise have permission to do, but doesn&#8217;t change what gets done.</p>
<h2>How do I remotely turn on a Linux server?</h2>
<p>Enter the BIOS of your server machine and enable the wake on lan/wake on network feature. &#8230;<br />
Boot your Ubuntu and run &#8220;sudo ethtool -s eth0 wol g&#8221; assuming eth0 is your network card. &#8230;<br />
run also &#8220;sudo ifconfig&#8221; and annotate the MAC address of the network card as it is required later to wake the PC.</p>
<h2>How do I restart a terminal server remotely?</h2>
<p>From the remote computer&#8217;s Start menu, select Run, and run a command line with optional switches to shut down the computer:<br />
To shut down, enter: shutdown.<br />
To reboot, enter: shutdown –r.<br />
To log off, enter: shutdown –l</p>
<h2>How do I send Ctrl Alt Del to remote desktop?</h2>
<p>Press the &#8220;CTRL,&#8221; &#8220;ALT&#8221; and &#8220;END&#8221; keys at the same time while you are viewing the Remote Desktop window. This command executes the traditional CTRL+ALT+DEL command on the remote computer instead of on your local computer.</p>
<h2>How do I remotely restart a server by IP address?</h2>
<p>Type “shutdown -m \ [IP Address] -r -f” (without quotes) at the command prompt, where &#8220;[IP Address]&#8221; is the IP of the computer you want to restart. For example, if the computer you want to restart is located at 192.168. 0.34, type “shutdown -m \ 192.168.</p>
<h2>How do I reboot from command prompt?</h2>
<ol>
<li>From an open command prompt window:</li>
<li>type shutdown, followed by the option you wish to execute.</li>
<li>To shut down your computer, type shutdown /s.</li>
<li>To restart your computer, type shutdown /r.</li>
<li>To log off your computer type shutdown /l.</li>
<li>For a complete list of options type shutdown /?</li>
<li>After typing your chosen option, press Enter.</li>
</ol>
<h2>How does Linux reboot work?</h2>
<p>The reboot command is used to restart a computer without turning the power off and then back on. If reboot is used when the system is not in runlevel 0 or 6 (i.e., the system is operating normally), then it invokes the shutdown command with its -r (i.e., reboot) option.</p>
<p><a class="a2a_button_mastodon" href="https://www.addtoany.com/add_to/mastodon?linkurl=https%3A%2F%2Flinuxcent.com%2Fhow-to-shutdown-or-reboot-a-remote-linux-host-from-commandline%2F&amp;linkname=How%20to%20Shutdown%20or%20Reboot%20a%20remote%20Linux%20Host%20from%20commandline" title="Mastodon" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_email" href="https://www.addtoany.com/add_to/email?linkurl=https%3A%2F%2Flinuxcent.com%2Fhow-to-shutdown-or-reboot-a-remote-linux-host-from-commandline%2F&amp;linkname=How%20to%20Shutdown%20or%20Reboot%20a%20remote%20Linux%20Host%20from%20commandline" title="Email" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_whatsapp" href="https://www.addtoany.com/add_to/whatsapp?linkurl=https%3A%2F%2Flinuxcent.com%2Fhow-to-shutdown-or-reboot-a-remote-linux-host-from-commandline%2F&amp;linkname=How%20to%20Shutdown%20or%20Reboot%20a%20remote%20Linux%20Host%20from%20commandline" title="WhatsApp" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Flinuxcent.com%2Fhow-to-shutdown-or-reboot-a-remote-linux-host-from-commandline%2F&amp;linkname=How%20to%20Shutdown%20or%20Reboot%20a%20remote%20Linux%20Host%20from%20commandline" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_x" href="https://www.addtoany.com/add_to/x?linkurl=https%3A%2F%2Flinuxcent.com%2Fhow-to-shutdown-or-reboot-a-remote-linux-host-from-commandline%2F&amp;linkname=How%20to%20Shutdown%20or%20Reboot%20a%20remote%20Linux%20Host%20from%20commandline" title="X" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Flinuxcent.com%2Fhow-to-shutdown-or-reboot-a-remote-linux-host-from-commandline%2F&amp;linkname=How%20to%20Shutdown%20or%20Reboot%20a%20remote%20Linux%20Host%20from%20commandline" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_copy_link" href="https://www.addtoany.com/add_to/copy_link?linkurl=https%3A%2F%2Flinuxcent.com%2Fhow-to-shutdown-or-reboot-a-remote-linux-host-from-commandline%2F&amp;linkname=How%20to%20Shutdown%20or%20Reboot%20a%20remote%20Linux%20Host%20from%20commandline" title="Copy Link" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Flinuxcent.com%2Fhow-to-shutdown-or-reboot-a-remote-linux-host-from-commandline%2F&#038;title=How%20to%20Shutdown%20or%20Reboot%20a%20remote%20Linux%20Host%20from%20commandline" data-a2a-url="https://linuxcent.com/how-to-shutdown-or-reboot-a-remote-linux-host-from-commandline/" data-a2a-title="How to Shutdown or Reboot a remote Linux Host from commandline"></a></p><p>The post <a href="https://linuxcent.com/how-to-shutdown-or-reboot-a-remote-linux-host-from-commandline/">How to Shutdown or Reboot a remote Linux Host from commandline</a> appeared first on <a href="https://linuxcent.com">Linuxcent</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://linuxcent.com/how-to-shutdown-or-reboot-a-remote-linux-host-from-commandline/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">102</post-id>	</item>
		<item>
		<title>chown and chgrp commands to change ownership of files and directories in Linux</title>
		<link>https://linuxcent.com/chown-and-chgrp-commands-to-change-ownership-of-files-and-directories-in-linux/</link>
					<comments>https://linuxcent.com/chown-and-chgrp-commands-to-change-ownership-of-files-and-directories-in-linux/#respond</comments>
		
		<dc:creator><![CDATA[Vamshi Krishna Santhapuri]]></dc:creator>
		<pubDate>Wed, 08 Mar 2023 04:20:54 +0000</pubDate>
				<category><![CDATA[Commands]]></category>
		<guid isPermaLink="false">https://linuxcent.com/?p=206</guid>

					<description><![CDATA[<p><span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> 5</span> <span class="rt-label rt-postfix">minutes</span></span>The commands chown and chgrp are extensively used in linux systems to update the ownership and organize the file structure. TL;DR: The command can be implemented in the following two types of notations. 1) User and group owner Symbolic notation 2) Reference operator The options/filters will be common to them for the two kinds on ... <a title="chown and chgrp commands to change ownership of files and directories in Linux" class="read-more" href="https://linuxcent.com/chown-and-chgrp-commands-to-change-ownership-of-files-and-directories-in-linux/" aria-label="Read more about chown and chgrp commands to change ownership of files and directories in Linux">Read more</a></p>
<p>The post <a href="https://linuxcent.com/chown-and-chgrp-commands-to-change-ownership-of-files-and-directories-in-linux/">chown and chgrp commands to change ownership of files and directories in Linux</a> appeared first on <a href="https://linuxcent.com">Linuxcent</a>.</p>
]]></description>
										<content:encoded><![CDATA[<span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> 5</span> <span class="rt-label rt-postfix">minutes</span></span><p>The commands chown and chgrp are extensively used in linux systems to update the ownership and organize the file structure.</p>
<p>TL;DR:<br />
The <code>chown</code> command can be implemented in the following two types of notations.<br />
1) User and group owner Symbolic notation<br />
2) Reference operator</p>
<p>The options/filters will be common to them for the two kinds on notations, We will look at the practical and important options.<br />
The <code>chown</code> command syntax:</p>
<pre>chown &lt;username&gt; &lt;data-directory&gt; &lt;files&gt;
chown &lt;username&gt;:&lt;groupname&gt; &lt;data-directory&gt;
chown --reference &lt;Source-reference-file| Source-reference-Directory&gt; &lt;data-directory&gt;</pre>
<p>The ownership of the files is a privileged operation and it requires a sudo access to the system<br />
Lets start by running the chown command on the files you want to change the ownership<br />
We have a file called jdk-8u141-linux-x64.rpm and its owned by root user.</p>
<pre>[vamshi@linuxcent ~]$ ls -l jdk-8u141-linux-x64.rpm
-rw-r--r--. 1 root root 169980729 Jul 13 2017 jdk-8u141-linux-x64.rpm</pre>
<p>We intend to change the ownership to user vamshi and we use <code>chown</code> command</p>
<pre>[vamshi@linuxcent ~]$ sudo chown -v vamshi jdk-8u141-linux-x64.rpm 
changed ownership of ‘jdk-8u141-linux-x64.rpm’ from root to vamshi</pre>
<pre>[vamshi@linuxcent ~]$ ls -l jdk-8u141-linux-x64.rpm
-rw-r--r--. 1 vamshi root 169980729 Jul 13  2017 jdk-8u141-linux-x64.rpm</pre>
<p>By this only the user part of ownership was modified but the group was uneffected.</p>
<p><em>NOTE: </em>We are using the option <code>-v</code> to print the command output information in verbose mode.</p>
<p>We can use <code>chgrp</code> command to modify the group ownership as follows:</p>
<pre>[vamshi@linuxcent ~]$ sudo chgrp -v vamshi jdk-8u141-linux-x64.rpm 
changed group of ‘jdk-8u141-linux-x64.rpm’ from root to vamshi</pre>
<p>To change both the user owner and group at once, chown command can be used, as demonstrated below:</p>
<pre>[vamshi@linuxcent ~]$ sudo chown -v vamshi:vamshi jdk-8u141-linux-x64.rpm 
changed ownership of ‘jdk-8u141-linux-x64.rpm’ from root:root to vamshi:vamshi

[vamshi@linuxcent ~]$ ls -l jdk-8u141-linux-x64.rpm
-rw-r--r--. 1 vamshi vamshi 169980729 Jul 13 2017 jdk-8u141-linux-x64.rpm</pre>
<h2>How do you recursively change the permissions within the destination sub-directories and files ?</h2>
<p><code>chown</code> command when used with <code>-R</code> applies the updated ownership recursively till the directory depth on destination.</p>
<pre>[vamshi@linuxcent data]$ ls -ld redmine/
drwxr-xr-x. 3 root root 17 Apr 17 16:31 redmine/</pre>
<pre>[vamshi@linuxcent data]$ sudo chown vamshi:vamshi /mnt/data/redmine/ -R</pre>
<pre>[vamshi@linuxcent data]$ ls -ld /mnt/data/redmine/
drwxrwxr-x. 3 vamshi vamshi 17 Apr 17 16:31 redmine-4.0.6</pre>
<h2>How to apply reference permissions to chown command in Linux ?</h2>
<p>We shall be using the option <code>--reference</code> which takes the reference from the existing file and applies the permission</p>
<p>Suppose we directory called djangoproject1.<br />
The root user copied the contents from elsewhere and placed  them in the location /home/alice .<br />
Now the user alice has to have the user ownership to them in-order to work with djangoproject1.</p>
<pre>[root@node02 alice]# ls -ld djangoproject1
drwxrwxr-x. 3 root root 108 Apr 16 11:45 djangoproject1</pre>
<p>We now file called requirements.txt and the file is owner by the user alice and has the owner following permissions</p>
<pre>[root@node02 alice]# ls -lth alice-requirements.txt
-rw-rw-r--. 1 alice alice 130 Apr 17 15:54 alice-requirements.txt</pre>
<p>So we can simply reference this file and apply the same ownership permissions to djangoproject1, Lets see the demonstration.</p>
<pre>[root@node02 alice]# sudo chown --reference alice-requirements.txt djangoproject1/ -R</pre>
<p>As a result we have successfully modified the user and group ownership to alice using the <code>--reference</code> operator; Applying the same ownership permissions as our reference file <code>alice-requirements.txt</code>.</p>
<pre>[root@node02 alice]# ls -lthr djangoproject1/*
-rw-rw-r--. 1 alice alice 405 Apr 16 11:44 djangoproject1/wsgi.py
-rw-rw-r--. 1 alice alice 756 Apr 16 11:44 djangoproject1/urls.py
-rw-rw-r--. 1 alice alice 3.1K Apr 16 11:44 djangoproject1/settings.py
-rw-rw-r--. 1 alice alice 0 Apr 16 11:44 djangoproject1/__init__.py
-rw-rw-r--. 1 alice alice 405 Apr 16 11:44 djangoproject1/asgi.py

djangoproject1/__pycache__:
total 8.0K
-rw-rw-r--. 1 alice alice 2.3K Apr 16 11:45 settings.cpython-36.pyc
-rw-rw-r--. 1 alice alice 159 Apr 16 11:45 __init__.cpython-36.pyc</pre>
<p>Thus we can use the chown command to update the ownership information to files and directories and also use the chgrp command as per requirement.</p>
<h2>How do I use chgrp in Linux?</h2>
<p>chgrp command in Linux is used to change the group ownership of a file or directory. All files in Linux belong to an owner and a group. You can set the owner by using “chown” command, and the group by the “chgrp” command.</p>
<h2>Who can use the chgrp command?</h2>
<p>You must use sudo with chgrp . Groups are not owned by users, so whether a file or directory is moved from one group to another is not a decision that sits with the average user. That&#8217;s a job for someone with root privileges.</p>
<h2>What is the difference between chown and chgrp?</h2>
<p>The chown command is used to change file or directory ownership. &#8230; Actually the chown command can be used to change both user and group ownership, while the chgrp command can only be used to change group ownership.</p>
<h2>Is chgrp recursive?</h2>
<p>To recursively change the group ownership of all files and directories under a given directory, use the -R option. Other options that can be used when recursively changing the group ownership are -H and -L . If the argument passed to chgrp command is a symbolic link, the -H option will cause the command to traverse it.</p>
<h2>What does Chgrp mean in Linux?</h2>
<p>The chgrp (from change group) command may be used by unprivileged users on Unix-like systems to change the group associated with a file system object (such as a file, directory, or link) to one of which they are a member.</p>
<h2>How do you give ownership in Linux?</h2>
<p>How to Change the Owner of a File</p>
<ol>
<li>Become superuser or assume an equivalent role.</li>
<li>Change the owner of a file by using the chown command. # chown new-owner filename. new-owner. Specifies</li>
<li>the user name or UID of the new owner of the file or directory. filename. &#8230;<br />
Verify that the owner of the file has changed. # ls -l filename.</li>
</ol>
<h2>What is G&#8217;s permission in Linux?</h2>
<p>chmod g+s .; This command sets the &#8220;set group ID&#8221; (setgid) mode bit on the current directory, written as . . This means that all new files and subdirectories created within the current directory inherit the group ID of the directory, rather than the primary group ID of the user who created the file.</p>
<h2>How do you ping on Linux?</h2>
<p>Click or double-click the Terminal app icon—which resembles a black box with a white &#8220;&gt;_&#8221; in it—or press Ctrl + Alt + T at the same time. Type in the &#8220;ping&#8221; command. Type in ping followed by the web address or IP address of the website you want to ping.</p>
<h2>Who can access a file with permission 000?</h2>
<p>File with 000 permission can be read / written by root. Everybody else cannot read / write / execute the file.</p>
<h2>What are the chown and chgrp commands used for?</h2>
<p>The chown command changes the owner of a file, and the chgrp command changes the group. On Linux, only root can use chown for changing ownership of a file, but any user can change the group to another group he belongs to.</p>
<h2>How do you chown chgrp?</h2>
<p>Stupid simple command to change ownership (chown) and change group (chgrp) at the same time. To simultaneously change both the owner and group of files or directories in linux use the following command structure: chown someusername:somegroupname filename.</p>
<h2>What do you mean by chmod chown and chgrp commands give example for each?</h2>
<p>These permissions read, write and execute permission for owner, group, and others. &#8230; Example: Give read/write/execute permission to the user, read/execute permission to the group, and execute permission to others. $ chmod 751 file1. #2) chown: Change ownership of the file.</p>
<p><a class="a2a_button_mastodon" href="https://www.addtoany.com/add_to/mastodon?linkurl=https%3A%2F%2Flinuxcent.com%2Fchown-and-chgrp-commands-to-change-ownership-of-files-and-directories-in-linux%2F&amp;linkname=chown%20and%20chgrp%20commands%20to%20change%20ownership%20of%20files%20and%20directories%20in%20Linux" title="Mastodon" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_email" href="https://www.addtoany.com/add_to/email?linkurl=https%3A%2F%2Flinuxcent.com%2Fchown-and-chgrp-commands-to-change-ownership-of-files-and-directories-in-linux%2F&amp;linkname=chown%20and%20chgrp%20commands%20to%20change%20ownership%20of%20files%20and%20directories%20in%20Linux" title="Email" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_whatsapp" href="https://www.addtoany.com/add_to/whatsapp?linkurl=https%3A%2F%2Flinuxcent.com%2Fchown-and-chgrp-commands-to-change-ownership-of-files-and-directories-in-linux%2F&amp;linkname=chown%20and%20chgrp%20commands%20to%20change%20ownership%20of%20files%20and%20directories%20in%20Linux" title="WhatsApp" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Flinuxcent.com%2Fchown-and-chgrp-commands-to-change-ownership-of-files-and-directories-in-linux%2F&amp;linkname=chown%20and%20chgrp%20commands%20to%20change%20ownership%20of%20files%20and%20directories%20in%20Linux" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_x" href="https://www.addtoany.com/add_to/x?linkurl=https%3A%2F%2Flinuxcent.com%2Fchown-and-chgrp-commands-to-change-ownership-of-files-and-directories-in-linux%2F&amp;linkname=chown%20and%20chgrp%20commands%20to%20change%20ownership%20of%20files%20and%20directories%20in%20Linux" title="X" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Flinuxcent.com%2Fchown-and-chgrp-commands-to-change-ownership-of-files-and-directories-in-linux%2F&amp;linkname=chown%20and%20chgrp%20commands%20to%20change%20ownership%20of%20files%20and%20directories%20in%20Linux" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_copy_link" href="https://www.addtoany.com/add_to/copy_link?linkurl=https%3A%2F%2Flinuxcent.com%2Fchown-and-chgrp-commands-to-change-ownership-of-files-and-directories-in-linux%2F&amp;linkname=chown%20and%20chgrp%20commands%20to%20change%20ownership%20of%20files%20and%20directories%20in%20Linux" title="Copy Link" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Flinuxcent.com%2Fchown-and-chgrp-commands-to-change-ownership-of-files-and-directories-in-linux%2F&#038;title=chown%20and%20chgrp%20commands%20to%20change%20ownership%20of%20files%20and%20directories%20in%20Linux" data-a2a-url="https://linuxcent.com/chown-and-chgrp-commands-to-change-ownership-of-files-and-directories-in-linux/" data-a2a-title="chown and chgrp commands to change ownership of files and directories in Linux"></a></p><p>The post <a href="https://linuxcent.com/chown-and-chgrp-commands-to-change-ownership-of-files-and-directories-in-linux/">chown and chgrp commands to change ownership of files and directories in Linux</a> appeared first on <a href="https://linuxcent.com">Linuxcent</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://linuxcent.com/chown-and-chgrp-commands-to-change-ownership-of-files-and-directories-in-linux/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">206</post-id>	</item>
		<item>
		<title>BASH &#8220;switch case&#8221; in Linux with practical example</title>
		<link>https://linuxcent.com/bash-switch-case-in-linux-with-practical-example/</link>
					<comments>https://linuxcent.com/bash-switch-case-in-linux-with-practical-example/#respond</comments>
		
		<dc:creator><![CDATA[Vamshi Krishna Santhapuri]]></dc:creator>
		<pubDate>Wed, 08 Mar 2023 03:33:26 +0000</pubDate>
				<category><![CDATA[Commands]]></category>
		<category><![CDATA[Linux Tutorials]]></category>
		<guid isPermaLink="false">https://linuxcent.com/?p=118</guid>

					<description><![CDATA[<p><span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> 4</span> <span class="rt-label rt-postfix">minutes</span></span>The switch case in BASH is more relevant and is widely used among the Linux admins/Devops folks to leverage the power of control flow in shell scripts. As we have seen the Control Structure: Bash If then Else. The switch case has a stronger case where it really simplifies out the control flow by running ... <a title="BASH &#8220;switch case&#8221; in Linux with practical example" class="read-more" href="https://linuxcent.com/bash-switch-case-in-linux-with-practical-example/" aria-label="Read more about BASH &#8220;switch case&#8221; in Linux with practical example">Read more</a></p>
<p>The post <a href="https://linuxcent.com/bash-switch-case-in-linux-with-practical-example/">BASH &#8220;switch case&#8221; in Linux with practical example</a> appeared first on <a href="https://linuxcent.com">Linuxcent</a>.</p>
]]></description>
										<content:encoded><![CDATA[<span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> 4</span> <span class="rt-label rt-postfix">minutes</span></span><p>The switch case in BASH is more relevant and is widely used among the Linux admins/Devops folks to leverage the power of control flow in shell scripts.</p>
<p>As we have seen the <code>if..elif..else..fi</code> <a href="https://linuxcent.com/control-structure-bash-if-then-else/">Control Structure: Bash If then Else</a>. The switch case has a stronger case where it really simplifies out the control flow by running the specific block of bash code based on the user selection or the input parameters.</p>
<p>Let’s take a look at the simple Switch case as follows:</p>
<pre>OPTION=$1
case $OPTION in
choice1)
Choice1 Statements
;;

choice2)
Choice2 Statements
;;

choiceN)
ChoiceN Statements
;;

*)
echo “User Selected Choice not present”
exit 1

esac</pre>
<p>The <code>OPTION</code> is generally read from user input and upon this the specific choice case block is invoked.</p>
<p><strong>Explanation:</strong><br />
In the switch command the control flow is forwarded to case keyword and stops here, it checks for the suitable match to pass over the control to relevant <code>OPTION</code>/<code>CHOICE</code> statement block. Upon the execution of the relevant CHOICE statements the case is exited once the control flow encounters <code>esac</code> keyword at the end.</p>
<p>Using the Pattern match<br />
The control flow in bash identifies the case options and proceeds accordingly.<br />
There can be cases where you can match the Here you might have observed that the user input the regular expression and the logical operators using the | for the input case</p>
<pre>#! /bin/bash

echo -en "Enter your logins\nUsername: "
read user_name 
echo -en "Password: "
read user_pass 
while [ -n $user_name -a -n $user_pass ]
do

case $user_name in
    ro*|admin)
        if [ "$user_pass" = "Root" ];
        then
            echo -e "Authentication succeeded \ n You Own this Machine"
	    break
        else
            echo -e "Authentication failure"
            exit
        fi
    ;;
    jenk*)
	if [ "$user_pass" = "Jenkins" ];
	then
		echo "Your home directory is /var/lib/jenkins"
	    	break
	else
        	echo -e "Authentication failure"
	fi
        break
    ;;
    *)
        echo -e "An unexpected error has occurred."
        exit
    ;;
esac

done
</pre>
<p>You should kindly note that the regex used for the cases at <code>ro*|admin</code> and <code>jenk*</code></p>
<p>We now have demonstrated by entering the username as <code>jenkins</code> and this will get matched with the jenkins case the control flow successfully enters into relevant block of code, checking the password match or not is not relevant for us as we are only concerned till the case choice selection.<br />
We have named the switch case into a script switch-case.sh and run it, Here are the results.</p>
<h2>OUTPUT :</h2>
<pre>[vamshi@node02 switch-case]$ sh switch-case.sh
Enter your logins
Username: jenkins
Password: Jenkins
Your home directory is /var/lib/jenkins</pre>
<p>We have entered the correct password and successfully runs the jenkins case block statements</p>
<p>We shall also see the or ro*|admin case, demonstrated as follows.</p>
<pre>[vamshi@node02 switch-case]$ sh switch-case.sh 
Enter your logins
Username: root
Password: Root
Authentication succeeded \ n You Own this Machine</pre>
<p>We now test the <code>admin</code> username and see the results.</p>
<pre>[vamshi@node02 switch-case]$ sh switch-case.sh 
Enter your logins
Username: admin
Password: Root
Authentication succeeded \ n You Own this Machine</pre>
<p>Here is a more advanced script used to deploy a python application using the switch case..<br />
Please refer to the Command line arguments section for user input</p>
<p>A complete functional Bash switch case can be seen at <a href="https://github.com/rrskris/python-deployment-script/blob/master/deploy-python.sh">https://github.com/rrskris/python-deployment-script/blob/master/deploy-python.sh</a></p>
<p>Please feel free to share your experiences in comments.</p>
<h2>What is switch in bash?</h2>
<p>The Bash case statement has a similar concept with the Javascript or C switch statement. The main difference is that unlike the C switch statement, the Bash case statement doesn&#8217;t continue to search for a pattern match once it has found one and executed statements associated with that pattern.</p>
<h2>How do you write a switch case in shell?</h2>
<p>In shell scripting switch case is represented using keywords case and esac which will do multilevel branching and checking in a better way than multiple if-else conditions. Switch case will need an expression which it needs to evaluate and need to perform multiple operations based on the outcome of the expression.</p>
<h2>How does case work in bash?</h2>
<p><strong>5 Bash Case Statement Examples</strong></p>
<ol>
<li>Case statement first expands the expression and tries to match it against each pattern.</li>
<li>When a match is found all of the associated statements until the double semicolon (;;) are executed.</li>
<li>After the first match, case terminates with the exit status of the last command that was executed.</li>
</ol>
<h2>What is the use of switch case in Unix shell scripting?</h2>
<p>Switch case in shell scripts is an efficient alternative to the if-elif-else statement that we learned previously. The concept of the switch case statements is that we provide different cases (conditions) to the statement that, when fulfilled, will execute specific blocks of commands.</p>
<h2>Which command is used for switch case in Linux script?</h2>
<p>esac statement is to give an expression to evaluate and to execute several different statements based on the value of the expression. The interpreter checks each case against the value of the expression until a match is found. If nothing matches, a default condition will be used.</p>
<h2>What is a switch or option in command line?</h2>
<p>A command line switch (also known as an option, a parameter, or a flag) acts as a modifier to the command you are issuing in the Command Prompt window, in a batch file, or in other scripts. Usually, a switch is a single letter preceded by a forward slash.</p>
<h2>What is ESAC bash?</h2>
<p>The esac keyword is indeed a required delimiter to end a case statement in bash and most shells used on Unix/Linux excluding the csh family. The original Bourne shell was created by Steve Bourne who previously worked on ALGOL68. This language invented this reversed word technique to delimit blocks.</p>
<h2>What is Getopts in shell script?</h2>
<p>getopts is a built-in Unix shell command for parsing command-line arguments. It is designed to process command line arguments that follow the POSIX Utility Syntax Guidelines, based on the C interface of getopt. The predecessor to getopts was the external program getopt by Unix System Laboratories.</p>
<p>&nbsp;</p>
<p><a class="a2a_button_mastodon" href="https://www.addtoany.com/add_to/mastodon?linkurl=https%3A%2F%2Flinuxcent.com%2Fbash-switch-case-in-linux-with-practical-example%2F&amp;linkname=BASH%20%E2%80%9Cswitch%20case%E2%80%9D%20in%20Linux%20with%20practical%20example" title="Mastodon" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_email" href="https://www.addtoany.com/add_to/email?linkurl=https%3A%2F%2Flinuxcent.com%2Fbash-switch-case-in-linux-with-practical-example%2F&amp;linkname=BASH%20%E2%80%9Cswitch%20case%E2%80%9D%20in%20Linux%20with%20practical%20example" title="Email" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_whatsapp" href="https://www.addtoany.com/add_to/whatsapp?linkurl=https%3A%2F%2Flinuxcent.com%2Fbash-switch-case-in-linux-with-practical-example%2F&amp;linkname=BASH%20%E2%80%9Cswitch%20case%E2%80%9D%20in%20Linux%20with%20practical%20example" title="WhatsApp" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Flinuxcent.com%2Fbash-switch-case-in-linux-with-practical-example%2F&amp;linkname=BASH%20%E2%80%9Cswitch%20case%E2%80%9D%20in%20Linux%20with%20practical%20example" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_x" href="https://www.addtoany.com/add_to/x?linkurl=https%3A%2F%2Flinuxcent.com%2Fbash-switch-case-in-linux-with-practical-example%2F&amp;linkname=BASH%20%E2%80%9Cswitch%20case%E2%80%9D%20in%20Linux%20with%20practical%20example" title="X" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Flinuxcent.com%2Fbash-switch-case-in-linux-with-practical-example%2F&amp;linkname=BASH%20%E2%80%9Cswitch%20case%E2%80%9D%20in%20Linux%20with%20practical%20example" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_copy_link" href="https://www.addtoany.com/add_to/copy_link?linkurl=https%3A%2F%2Flinuxcent.com%2Fbash-switch-case-in-linux-with-practical-example%2F&amp;linkname=BASH%20%E2%80%9Cswitch%20case%E2%80%9D%20in%20Linux%20with%20practical%20example" title="Copy Link" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Flinuxcent.com%2Fbash-switch-case-in-linux-with-practical-example%2F&#038;title=BASH%20%E2%80%9Cswitch%20case%E2%80%9D%20in%20Linux%20with%20practical%20example" data-a2a-url="https://linuxcent.com/bash-switch-case-in-linux-with-practical-example/" data-a2a-title="BASH “switch case” in Linux with practical example"></a></p><p>The post <a href="https://linuxcent.com/bash-switch-case-in-linux-with-practical-example/">BASH &#8220;switch case&#8221; in Linux with practical example</a> appeared first on <a href="https://linuxcent.com">Linuxcent</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://linuxcent.com/bash-switch-case-in-linux-with-practical-example/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">118</post-id>	</item>
		<item>
		<title>Linux cut command with practical examples</title>
		<link>https://linuxcent.com/linux-cut-command-with-practical-examples/</link>
					<comments>https://linuxcent.com/linux-cut-command-with-practical-examples/#respond</comments>
		
		<dc:creator><![CDATA[Vamshi Krishna Santhapuri]]></dc:creator>
		<pubDate>Wed, 08 Mar 2023 03:31:14 +0000</pubDate>
				<category><![CDATA[Commands]]></category>
		<guid isPermaLink="false">https://linuxcent.com/?p=218</guid>

					<description><![CDATA[<p><span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> 5</span> <span class="rt-label rt-postfix">minutes</span></span>The Linux cut command, extracts the sections of text from the input lines of files. The general syntax cut [OPTION] [FILE] The cut command offers special characters like and to extract the range and selection of data from input line or stream of lines read from a file. The cut command has some most useful ... <a title="Linux cut command with practical examples" class="read-more" href="https://linuxcent.com/linux-cut-command-with-practical-examples/" aria-label="Read more about Linux cut command with practical examples">Read more</a></p>
<p>The post <a href="https://linuxcent.com/linux-cut-command-with-practical-examples/">Linux cut command with practical examples</a> appeared first on <a href="https://linuxcent.com">Linuxcent</a>.</p>
]]></description>
										<content:encoded><![CDATA[<span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> 5</span> <span class="rt-label rt-postfix">minutes</span></span><p>The Linux cut command, extracts the sections of text from the input lines of files.</p>
<p>The general syntax</p>
<pre>cut [OPTION] [FILE]</pre>
<p>The cut command offers special characters like <code>-</code> and <code>,</code> to extract the range and selection of data from input line or stream of lines read from a file.</p>
<p>The cut command has some most useful and quick options to extract data from the input lines..</p>
<p>First such option is <code>-b</code>, <code>--bytes=</code>LIST from the Specified LIST</p>
<p>Using the <code>-b</code> option we shall be able to extract the specific byte characters.</p>
<pre>$ echo -e "Exploring the practical use of cut command"</pre>
<p>For getting the specific byte index from input stream list:</p>
<pre>echo -e "Exploring the practical use of cut command"  | cut -b 3
p</pre>
<p>Extracting the range of bytes from input stream list:</p>
<pre>[vamshi@linuxcent ~]$ echo -e "Exploring the practical use of cut command"  | cut -b 3-6
plor</pre>
<p>Extracting the bytes from starting till the given index range</p>
<pre>[vamshi@linuxcent ~]$ echo -e "Exploring the practical use of cut command"  | cut -b -6
Explor</pre>
<p>Extracting the bytes from given index range till the end of the input line</p>
<pre>[vamshi@linuxcent ~]$ echo -e "Exploring the practical use of cut command"  | cut -b 3-
ploring the practical use of cut command</pre>
<p>Combining the , and &#8211; operations and extracting the bytes from the input lines:</p>
<pre>[vamshi@node02 Linux-blog]$ echo -e "Exploring the practical use of cut command"  | cut -b 1,2-6,9
Explorg</pre>
<p>First such option is <code>-c</code>, <code>--characters=</code>LIST from the Specified LIST</p>
<p>Extracting the specific character from the input string:</p>
<pre>[vamshi@node02 Linux-blog]$ echo -e "Exploring the practical use of cut command"  | cut -c 11
t</pre>
<p>Extracting the range of bytes from input stream list:</p>
<pre>[vamshi@linuxcent ~]$ echo -e "Exploring the practical use of cut command"  | cut -c 11-24
the practical</pre>
<p>Getting the range of the characters from given index till the end of the input line using <code>-</code></p>
<pre>[vamshi@node02 Linux-blog]$ echo -e "Exploring the practical use of cut command"  | cut -c 11-

the practical use of cut command</pre>
<p>Using <code>-</code> to get the characters from starting till the given index range</p>
<pre>[vamshi@node02 Linux-blog]$ echo -e "Exploring the practical use of cut command"  | cut -c -9

Exploring</pre>
<p>We have a Text file called README with the following content.</p>
<pre>The following are Most popular Linux server Distributions and their curent versions:

Distribution Versions
----------- --------
Redhat : 8.0
Ubuntu : 18.04
Centos : 8.0
Debian : 10.1
SUSE : 15.1</pre>
<p>Extracting the fields from the given data file using <code>-f</code>, separated by the tabs which is a default delimited.</p>
<p>Lets try and extract the field from <code>README</code> datafile.</p>
<pre>$ cat README | cut -f1
[vamshi@linuxcent ~]$ cut -f1 README
The following are Most popular Linux server Distributions and their current versions:

Distribution
-----------
Redhat
Ubuntu
Centos
Debian
SUSE</pre>
<p>The options and ranges can also be mentioned in the field option to extract relevant data.<br />
Extracting the fields indexed by numbers from given file separated by tabs</p>
<pre>$ cat README | cut -f1,2,3
$ cut -f1,2,3 README</pre>
<p>Extracting the first field through 3rd field from the given file separated by tabs</p>
<pre>$ cat README | cut -f1-3 
$ cut -f1-3 README</pre>
<p>A lot of combinations can be used to extract the ranges as shows below:</p>
<pre>$ cat README | cut -f 3- 
</pre>
<p>We will also like to shed some light on the <code>--complement</code> option, As the option name hints, it will print only the inverse of the operation, It can be used in conjunction with <code>-b</code> , <code>-c</code> and <code>-f</code> respectively:</p>
<p>For example</p>
<pre>[vamshi@linuxcent Linux-blog]$ echo -e "Exploring the practical use of cut command" | cut -c1 --complement
xploring the practical use of cut command</pre>
<p>The first character E is excluded and then remaining characters are printed because of &#8211;complement option being used in conjunction.</p>
<p>Delimiter Option <code>-d</code>, <code>--bytes=</code>DELIM from the Specified LIST<br />
Unlike the field extractor option which only set to default single tab space as Delimiter, The Delimiter option provides the flexibility to setup a custom Delimiter to any character. Widely used for setting a Delimiter other than a Tab.</p>
<p>Lets take an example of the line following input line:</p>
<pre>dockerroot:x:996:992:Docker User:/var/lib/docker:/sbin/nologin</pre>
<p>The delimit option <code>-d</code>can be set to :  and have the combination of fields and characters/bytes to highly customize and refine the extract text.</p>
<pre>[vamshi@linuxcent Linux-blog]$ cat /etc/passwd | grep docker | cut -d":" -f1
dockerroot</pre>
<pre>[vamshi@linuxcent Linux-blog]$ cat /etc/passwd | grep docker | cut -d"/" -f1-5
dockerroot:x:996:992:Docker User:/var/lib/docker:/sbin</pre>
<p>The same logic of obtaining and extracting the ranges and specific field extractions is applied commonly in cut command.</p>
<p>A very special mentioning of the operator <code>-s</code> or <code>--only-delimited</code>, Which prints only the lines modified by the <code>cut</code> command and delimited by the delimit operator.</p>
<pre>[vamshi@linuxcent Linux-blog]$ cat README | cut -d":" -f1 -s
The following are Most popular Linux server Distributions and their curent versions
Redhat 
Ubuntu 
Centos 
Debian 
SUSE</pre>
<p>The option <code>--output-delimiter=&quot;STRING&quot;</code> takes a string as its input and then substitutes it with the actual delimiter:</p>
<p>Lets look at the below practical example:</p>
<pre>[vamshi@node02 Linux-blog]$ cat /etc/passwd | grep docker | cut -d":" -f1- --output-delimiter=' '
dockerroot x 996 992 Docker User /var/lib/docker /sbin/nologin</pre>
<h2>Format the Output to print newline using cut command:</h2>
<pre>[vamshi@linuxcent  ~]$ cat /etc/passwd | grep docker | cut -d":" -f1- --output-delimiter=$'\n'
dockerroot
x
996
992
Docker User
/var/lib/docker
/sbin/nologin</pre>
<p>The <code>output-delimiter</code> formatting the output by replacing the delimiter with a newline character using <code>$&#039;\n&#039;</code> thus printing the output separated by the newline</p>
<h2>How use cut in Linux?</h2>
<p>It can be used to cut parts of a line by byte position, character and field. Basically the cut command slices a line and extracts the text. It is necessary to specify option with command otherwise it gives error. If more than one file name is provided then data from each file is not precedes by its file name.</p>
<h2>What does the cut command do?</h2>
<p>The cut command is a command-line utility for cutting sections from each line of a file. It writes the result to the standard output.</p>
<h2>How do I cut a word in Linux?</h2>
<p>CUT<br />
Most important Options:</p>
<ol>
<li>-b, &#8211;bytes=LIST # select only these bytes.</li>
<li>-c, &#8211;characters=LIST # select only these characters.</li>
<li>-d, &#8211;delimiter=DELIM # use DELIM instead of TAB for field delimiter.</li>
</ol>
<h2>What is cut in bash?</h2>
<p>The cut command is used to extract the specific portion of text in a file. Many options can be added to the command to exclude unwanted items. It is mandatory to specify an option in the command otherwise it shows an error. In this article, we will throw light on each option of the cut command.</p>
<h2>How do you cut on the keyboard?</h2>
<p>Keyboard shortcuts</p>
<ol>
<li>Copy: Ctrl+C.</li>
<li>Cut: Ctrl+X.</li>
<li>Paste: Ctrl+V.</li>
</ol>
<h2>How do you trim in Unix?</h2>
<p>Example-2: Trim string data using `sed` command</p>
<p>Use sed &#8216;s/^ *//g&#8217;, to remove the leading white spaces. There is another way to remove whitespaces using `sed` command. The following commands removed the spaces from the variable, $Var by using `sed` command and [[:space:]].</p>
<h2>What does cut do Unix?</h2>
<p>In computing, cut is a command line utility on Unix and Unix-like operating systems which is used to extract sections from each line of input — usually from a file.</p>
<h2>How do you cut a column in Unix?</h2>
<p>The Linux cut command allows you to cut data by character, by field, or by column. if used correctly along with sed, find, or grep in UNIX, the cut can do lots of reporting stuff. For example, you can extract columns from a comma-separated file or a pipe or colon-delimited file using cut command.</p>
<h2>How do I trim a word in bash?</h2>
<p>${var// /} removes all space characters. There&#8217;s no way to trim just leading and trailing whitespace with only this construct. Bash “patterns” are regular expressions, only with a different syntax than “POSIX (extended) regular expressions”.</p>
<h2>How do I cut a word in bash?</h2>
<p>In Linux try Ctrl+k to delete from where the cursor is to the end of the word. There are few other shortcuts listed below(working in Linux): Ctrl+e -&gt; Takes cursor at the end of the word.</p>
<p><a class="a2a_button_mastodon" href="https://www.addtoany.com/add_to/mastodon?linkurl=https%3A%2F%2Flinuxcent.com%2Flinux-cut-command-with-practical-examples%2F&amp;linkname=Linux%20cut%20command%20with%20practical%20examples" title="Mastodon" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_email" href="https://www.addtoany.com/add_to/email?linkurl=https%3A%2F%2Flinuxcent.com%2Flinux-cut-command-with-practical-examples%2F&amp;linkname=Linux%20cut%20command%20with%20practical%20examples" title="Email" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_whatsapp" href="https://www.addtoany.com/add_to/whatsapp?linkurl=https%3A%2F%2Flinuxcent.com%2Flinux-cut-command-with-practical-examples%2F&amp;linkname=Linux%20cut%20command%20with%20practical%20examples" title="WhatsApp" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Flinuxcent.com%2Flinux-cut-command-with-practical-examples%2F&amp;linkname=Linux%20cut%20command%20with%20practical%20examples" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_x" href="https://www.addtoany.com/add_to/x?linkurl=https%3A%2F%2Flinuxcent.com%2Flinux-cut-command-with-practical-examples%2F&amp;linkname=Linux%20cut%20command%20with%20practical%20examples" title="X" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Flinuxcent.com%2Flinux-cut-command-with-practical-examples%2F&amp;linkname=Linux%20cut%20command%20with%20practical%20examples" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_copy_link" href="https://www.addtoany.com/add_to/copy_link?linkurl=https%3A%2F%2Flinuxcent.com%2Flinux-cut-command-with-practical-examples%2F&amp;linkname=Linux%20cut%20command%20with%20practical%20examples" title="Copy Link" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Flinuxcent.com%2Flinux-cut-command-with-practical-examples%2F&#038;title=Linux%20cut%20command%20with%20practical%20examples" data-a2a-url="https://linuxcent.com/linux-cut-command-with-practical-examples/" data-a2a-title="Linux cut command with practical examples"></a></p><p>The post <a href="https://linuxcent.com/linux-cut-command-with-practical-examples/">Linux cut command with practical examples</a> appeared first on <a href="https://linuxcent.com">Linuxcent</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://linuxcent.com/linux-cut-command-with-practical-examples/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">218</post-id>	</item>
		<item>
		<title>SVN commands</title>
		<link>https://linuxcent.com/svn-commands/</link>
					<comments>https://linuxcent.com/svn-commands/#respond</comments>
		
		<dc:creator><![CDATA[Vamshi Krishna Santhapuri]]></dc:creator>
		<pubDate>Tue, 07 Mar 2023 06:04:29 +0000</pubDate>
				<category><![CDATA[Commands]]></category>
		<guid isPermaLink="false">https://linuxcent.com/?p=310</guid>

					<description><![CDATA[<p><span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> 4</span> <span class="rt-label rt-postfix">minutes</span></span>SVN is Version controlling system and predates git, It was one of the most widely used version control system and served the community and still going on.. It had its own share advantages and shortcomings. In this tutorial we will shed some light on practical usecases of SVN and day-to-day activities. How to take a ... <a title="SVN commands" class="read-more" href="https://linuxcent.com/svn-commands/" aria-label="Read more about SVN commands">Read more</a></p>
<p>The post <a href="https://linuxcent.com/svn-commands/">SVN commands</a> appeared first on <a href="https://linuxcent.com">Linuxcent</a>.</p>
]]></description>
										<content:encoded><![CDATA[<span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> 4</span> <span class="rt-label rt-postfix">minutes</span></span><p>SVN is Version controlling system and predates git, It was one of the most widely used version control system and served the community and still going on.. It had its own share advantages and shortcomings.</p>
<p>In this tutorial we will shed some light on practical usecases of SVN and day-to-day activities.</p>
<p>How to take a dump of live svn repo by loading it to another Repo on the fly.</p>
<pre># svnadmin dump /opt/svn/ProjectCode | svnadmin load /opt/svn/ProjectCode</pre>
<p>SVN commands to take the dump from repo to a .dump file</p>
<pre># svnadmin dump /opt/svn/PST &gt; test.dump</pre>
<p>Using svn comands svnadmin to take the dump for specific revision number range from commandline.</p>
<pre># svnadmin dump -r 41:3601 /opt/svn/ProjectCode &gt; test.dump</pre>
<p>SVN Commands to split svn directories to respective svn repositories:</p>
<p>We have the folder structure of the ProjectCode and want to create a individual repository of all the folders with their own SVN repos, We can use the svndumpfilter to achieve the task.</p>
<pre>$ cat projectslist
./project1./project2
./project3
./project4
</pre>
<pre>$ for i in `cat projectslist`; do sudo svndumpfilter --drop-empty-revs --renumber-revs exclude `cat projectslist | grep -v $i` &lt; SVN.dump &gt; `echo $i | sed -e 's/\///g'`.dump; done</pre>
<h2>How to setup up a SVN repo from linux commandline.</h2>
<p>Creating Dir for new SVN</p>
<pre># mkdir /opt/svn/ProjectCode</pre>
<p>Initialize a repo in the newly created directory</p>
<pre>#svnadmin create /opt/svn/ProjectCode</pre>
<p>Load the repo from dump</p>
<pre>#svnadmin load --force-uuid /opt/svn/ProjectCode &lt; newProjectCode.dump</pre>
<p>Loading repo from dump and redirecting output to file</p>
<pre>#svnadmin load --force-uuid /opt/svn/ProjectCode &lt; newProjectCode.dump &gt;&gt; /root/pst.out &amp;</pre>
<p>Linux Commands To delete a repo; Make sure the svnserve process is in stopper state and not active while removing the repo.</p>
<pre># rm -rf /opt/svn/PST</pre>
<p>While taking SVN repo dump How to Exclude some paths from existing dump and create a new dump<br />
We will be using the exclude option and passing the exclude pattern</p>
<pre># svndumpfilter exclude `cat ProjectCode-exclude-somerolders` &lt; ProjectCode.dump &gt; new-exclude.dump</pre>
<p>Below is a sample exclude file with specific file names and directory paths</p>
<pre># cat ProjectCode-excludelist
/path/to/code/not/required
/Some/more/paths/and/specific-filenames.css
/code/static/test/</pre>
<p>How to check the logs from SVN repo from commandline</p>
<pre># svn log <code>file:///opt/svn/Project</code></pre>
<h2>How to setup SVN repository with configuration ?</h2>
<pre># svnadmin create /opt/svn</pre>
<p>Below is the example snippet from svnserve.conf</p>
<pre>[general]
anon-access = none
auth-access = write
password-db = /opt/svn/conf/passwd
authz-db = /opt/svn/conf/authz</pre>
<p>Here is the sample config snipet from authz</p>
<pre>[/]
svamshi = rw</pre>
<p>How to start SVN server from linux commandline</p>
<pre># svnserve --listen-host ip-address/project-repo -r /opt/svn/my-projectcode/ -d</pre>
<p>How to checkout a SVN repo from linux commandline</p>
<pre># svn co --username=svamshi --password=mypassword svn://ip-address/project-repo</pre>
<p>Adding the new created files to svn and then commit to svn.</p>
<pre># svn add linuxcent.html</pre>
<pre># svn commit -am "updated with linuxcent.html"</pre>
<h2>How to serve the SVN repository through Apache Httpd server.</h2>
<p>Example [/code]/opt/svn[/code]The svn module has to be downloaded</p>
<p>Below is the sample configuration of virtualhost informantion</p>
<p><img decoding="async" class="alignnone size-full wp-image-314" src="https://linuxcent.com/wp-content/uploads/2020/04/svn-subversion-repo-apache-conf.png" alt="subversion-apache-httpd-set-up-configuration" width="582" height="189" srcset="https://linuxcent.com/wp-content/uploads/2020/04/svn-subversion-repo-apache-conf.png 582w, https://linuxcent.com/wp-content/uploads/2020/04/svn-subversion-repo-apache-conf-300x97.png 300w" sizes="(max-width: 582px) 100vw, 582px" /></p>
<h2>What are the svn commands?</h2>
<p>Here are the basic SVN commands that every developer and admin should know.<br />
svn admincreate. The svn admincreate command creates a new, empty repository.</p>
<ul>
<li>svn import. &#8230;</li>
<li>svn checkout. &#8230;</li>
<li>svn commit. &#8230;</li>
<li>svn add. &#8230;</li>
<li>svn delete. &#8230;</li>
<li>svn list. &#8230;</li>
<li>svn diff.</li>
</ul>
<h2>How do I use svn in Linux?</h2>
<ol>
<li>Connect via SSH. In order to install SVN, connect to your Linux VPS via SSH. &#8230;</li>
<li>Update the OS Packages and Install SVN in Linux. If you are using an Ubuntu VPS, update the OS packages and install SVN on your server using the commands below: sudo apt-get update sudo apt-get install svn. &#8230;</li>
<li>Check SVN Version</li>
</ol>
<h2>What is svn up command?</h2>
<p>The svn update command lets you refresh your locally checked out repository with any changes in the repository HEAD on the server. It also tells you what has been changed, added, deleted. If a change has been made to a file you have also changed locally, svn will try to merge those changes.</p>
<h2>How do I run svn?</h2>
<ol>
<li>Open windows explorer.</li>
<li>Create a folder where you will store project files.</li>
<li>Right-click on the folder you created and select &#8220;SVN Checkout&#8221; (see image below).</li>
<li>When prompted, enter your username and password.</li>
<li>If everything worked, you now have a copy of the repository in your directory.</li>
</ol>
<h2>Which is Better Git or svn?</h2>
<p>Why SVN Is Better Than Git</p>
<p>SVN is better than Git for architecture performance, binary files, and usability. And it may be better for access control and auditability, based on your needs.</p>
<h2>Where are svn commands executed?</h2>
<p>If you want to run Subversion commands from the command prompt, you should run the svn.exe command line client. TortoiseSVN 1.6.</p>
<h2>How do I use shelve in svn?</h2>
<p>To shelve your local changes, select your working copy and use Context Menu → Shelve The following dialog allows you to select the files you want to shelve and give a name under which you want to store them. If you select an existing shelf, then a new version is created for that shelf.</p>
<h2>Does svn work on Linux?</h2>
<p>SVN Installation</p>
<p>Subversion is a popular open-source version control tool. It is open-source and available for free over the internet. It comes by default with most of the GNU/Linux distributions, so it might be already installed on your system.</p>
<h2>How configure svn server in Linux?</h2>
<p>How to Install SVN Server on Ubuntu 18.04 &amp; 16.04 LTS</p>
<ul>
<li>Step 1 – Install Apache. &#8230;</li>
<li>Step 2 – Install SVN Server. &#8230;</li>
<li>Step 3 – Create First SVN Repository. &#8230;</li>
<li>Step 4 – Create Users for Subversion. &#8230;</li>
<li>Step 5 – Configure Apache with Subversion. &#8230;</li>
<li>Step 6 – Access Repository in Browser.</li>
</ul>
<div class="wWOJcd" tabindex="0" role="button" aria-controls="exacc_5BuNYeiTDIzrwQPRjYboCQ10" aria-expanded="true" aria-labelledby="exacc_5BuNYeiTDIzrwQPRjYboCQ9">
<h2 id="exacc_5BuNYeiTDIzrwQPRjYboCQ9" class="iDjcJe IX9Lgd wwB5gf">Where is svn installed on Linux?</h2>
<div class="r21Kzd" data-hveid="CAkQAQ" data-ved="2ahUKEwjoldu2tpD0AhWMdXAKHdGGAZ0Quk56BAgJEAE">Did you try whereis svn ? Executables are usually in <b>/usr/bin or /usr/local/bin</b> .</div>
</div>
<h2 data-hveid="CAkQAQ" data-ved="2ahUKEwjoldu2tpD0AhWMdXAKHdGGAZ0Quk56BAgJEAE">How do you svn add all files?</h2>
<div data-hveid="CAkQAQ" data-ved="2ahUKEwjoldu2tpD0AhWMdXAKHdGGAZ0Quk56BAgJEAE">To add an existing file to a Subversion repository and put it under revision control, change to the directory with its working copy and run the following command: svn add file… Similarly, to add a directory and all files that are in it, type: svn add directory</div>
<div data-hveid="CAkQAQ" data-ved="2ahUKEwjoldu2tpD0AhWMdXAKHdGGAZ0Quk56BAgJEAE"></div>
<p><a class="a2a_button_mastodon" href="https://www.addtoany.com/add_to/mastodon?linkurl=https%3A%2F%2Flinuxcent.com%2Fsvn-commands%2F&amp;linkname=SVN%20commands" title="Mastodon" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_email" href="https://www.addtoany.com/add_to/email?linkurl=https%3A%2F%2Flinuxcent.com%2Fsvn-commands%2F&amp;linkname=SVN%20commands" title="Email" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_whatsapp" href="https://www.addtoany.com/add_to/whatsapp?linkurl=https%3A%2F%2Flinuxcent.com%2Fsvn-commands%2F&amp;linkname=SVN%20commands" title="WhatsApp" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Flinuxcent.com%2Fsvn-commands%2F&amp;linkname=SVN%20commands" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_x" href="https://www.addtoany.com/add_to/x?linkurl=https%3A%2F%2Flinuxcent.com%2Fsvn-commands%2F&amp;linkname=SVN%20commands" title="X" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Flinuxcent.com%2Fsvn-commands%2F&amp;linkname=SVN%20commands" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_copy_link" href="https://www.addtoany.com/add_to/copy_link?linkurl=https%3A%2F%2Flinuxcent.com%2Fsvn-commands%2F&amp;linkname=SVN%20commands" title="Copy Link" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Flinuxcent.com%2Fsvn-commands%2F&#038;title=SVN%20commands" data-a2a-url="https://linuxcent.com/svn-commands/" data-a2a-title="SVN commands"></a></p><p>The post <a href="https://linuxcent.com/svn-commands/">SVN commands</a> appeared first on <a href="https://linuxcent.com">Linuxcent</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://linuxcent.com/svn-commands/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">310</post-id>	</item>
		<item>
		<title>Linux Find command &#8211; with Practical examples</title>
		<link>https://linuxcent.com/linux-find-command-with-practical-examples/</link>
					<comments>https://linuxcent.com/linux-find-command-with-practical-examples/#respond</comments>
		
		<dc:creator><![CDATA[Vamshi Krishna Santhapuri]]></dc:creator>
		<pubDate>Wed, 01 Mar 2023 15:22:04 +0000</pubDate>
				<category><![CDATA[Commands]]></category>
		<guid isPermaLink="false">https://linuxcent.com/?p=112</guid>

					<description><![CDATA[<p><span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> 3</span> <span class="rt-label rt-postfix">minutes</span></span>The Linux find command utility is a powerful command in locating the files and directories at system wide level, the The basic syntax of find command is very straight forward. The number of filters and types of options you choose while forming the find command determines and complexity of the operation and is directly proportional ... <a title="Linux Find command &#8211; with Practical examples" class="read-more" href="https://linuxcent.com/linux-find-command-with-practical-examples/" aria-label="Read more about Linux Find command &#8211; with Practical examples">Read more</a></p>
<p>The post <a href="https://linuxcent.com/linux-find-command-with-practical-examples/">Linux Find command &#8211; with Practical examples</a> appeared first on <a href="https://linuxcent.com">Linuxcent</a>.</p>
]]></description>
										<content:encoded><![CDATA[<span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> 3</span> <span class="rt-label rt-postfix">minutes</span></span><p>The Linux find command utility is a powerful command in locating the files and directories at system wide level, the</p>
<p>The basic syntax of find command is very straight forward. The number of filters and types of options you choose while forming the find command determines and complexity of the operation and is directly proportional to the run time of the command.</p>
<p>Lets examine the general syntax of Linux <code>find</code> command line utility</p>
<pre>$ find [path] [Options/filters] [expression]</pre>
<h2>How to Find all the files that are modified within 1 day.</h2>
<pre>$ find . -mtime -1</pre>
<h2>Use find command to find all the files that are modified within last x Minutes</h2>
<pre>$ find . -mmin -360</pre>
<h2>How to Find all the files that are created within given Minutes</h2>
<pre>$ find . -cmin -360</pre>
<h2>How to Find all the files under a specific size on the filesystem.</h2>
<pre>$ find . -type f -size -100G</pre>
<p>NOTE: the <code>-</code> will find the files including and under the mentioned size</p>
<h2>How to find really big size files with a given size using Linux Find Command.</h2>
<pre>$ find . -type f -size +100G</pre>
<p>NOTE: the <code>+</code> will find the files exceeding the mentioned size</p>
<h3>How to Find all the files with a pattern match using Find command?</h3>
<pre>vamshi.santhapuri@linux-pc:~/Linux/Programs&gt; find *.py
my_program.py
myProgram.py
My_program.py</pre>
<p><strong>OutPut Demonstrated:</strong></p>
<pre>vamshi@linuxcent:~/Linux/Programs&gt; ls -l
total 0
-rwxr-xr-x 1 vamshi users 0 Apr 8 16:33 my_program.py
-rwxr-xr-x 1 vamshi users 0 Apr 8 16:32 myProgram.py
-rwxr-xr-x 1 vamshi users 0 Apr 8 16:32 My_program.py ex</pre>
<p>&nbsp;</p>
<h3>Find Files Based on file-type using option -type</h3>
<p>Find only the regular file type</p>
<pre>$ sudo find / -type f -print</pre>
<p>Find only the Directory</p>
<pre>$ sudo find / -type d -print</pre>
<p>Lets see some special file formats like character files as in network level files and block files as in storage device file type.</p>
<pre>$ sudo find /dev/ -type b -print
/dev/sdb8
/dev/sdb7
/dev/sdb6
/dev/sdb5
/dev/sdb4
/dev/sdb1
/dev/sdb
/dev/sda6
/dev/sda5
</pre>
<h2>How to find empty files and Directories in Linux using Find command?</h2>
<pre>$ find . -empty # Finds all files and directories that are empty
$ find . -type f -empty #Find onlt empty files
$ find . -type d -empty #Find only empty Directories</pre>
<h2>How to Find all the hidden files and directories using Find command</h2>
<p>You can also add the type flag as required</p>
<pre>$ find . -name ".*" //Prints all the files and directories that are hidden</pre>
<p>Find the character stream files and identify them yourselves.</p>
<pre>$ sudo find / -type c -print</pre>
<p>&nbsp;</p>
<h2><b>How to exclude some files or directories while using the find command?</b></h2>
<p>The negation Operator <code>!</code> in find command line</p>
<pre>[vamshi@linuxcent ~]$ find / -type d  ! -path /mount ! -path /mnt/3TB/</pre>
<h2>How to find the files with .py extension and then setting the execute permission on them ?</h2>
<p><code>-exec</code> is a special builtin option which takes the specified command on the selected files</p>
<pre>[vamshi@linuxcent ~]$ find *.py -exec chmod +x {} \;</pre>
<h2>A practical example of Finding and Deleting Big size files using Find Command</h2>
<p>We Demonstrate a Big thread dump file that we generated in our Test environment by finding it on our server and then deleting it.</p>
<pre>[vamshi@linuxcent ~]$ find /var -type f -size +100G -exec rm {} \;</pre>
<p>&nbsp;</p>
<p><b>To find the files with matching file permissions</b></p>
<pre>[vamshi@linuxcent ~]$ sudo find / -type f -perm 0600 -print</pre>
<p>More complex find operations can be performed by combining the negation operator and by excluding the certain mount points and using the logical AND OR operators.</p>
<p>For example:</p>
<pre>sudo find / -xdev -type d \( -perm -0002 -a ! -perm -1000 \) -exec ls -ld {} \;</pre>
<h2>Ignore case using the find command</h2>
<p>The filter <code>-iname</code> enables the find to perform case insesitive search.</p>
<pre>[vamshi@node02 Linux-blog]$ find . -iname "rEadMe*" 
./Debian-Distro/README-Debian-Distro
./OpenSuse-Distro/README-Opensuse-Distro
./README
./Redhat-Distro/Centos/README-CentOS
./Redhat-Distro/README-Redhat-Distro</pre>
<h2>How to use Maxdepth Option in the find command to explore the directory depth?</h2>
<pre>[vamshi@node02 Linux-blog]$ find . -maxdepth 1 -name "README*" 
./README</pre>
<p>By using find command filter option <code>-maxdepth</code> Now we can extract the results based on the one level deeper subdirectory, which is demonstrated as follows:</p>
<pre>[vamshi@node02 Linux-blog]$ find . -maxdepth 2 -name "README*" 
./Debian-Distro/README-Debian-Distro
./OpenSuse-Distro/README-Opensuse-Distro
./README
./Redhat-Distro/README-Redhat-Distro</pre>
<h2>How to use mindepth Option in the find command to restrict the results based on the subdirectory depth?</h2>
<p>The <code>-mindepth</code> filter option restricts the find command search to nth subdirectory level from the given path.</p>
<pre>[vamshi@node02 Linux-blog]$ find . -mindepth 3 -name "README*" 
./Redhat-Distro/Centos/README-CentOS</pre>
<p>&nbsp;</p>
<p><a class="a2a_button_mastodon" href="https://www.addtoany.com/add_to/mastodon?linkurl=https%3A%2F%2Flinuxcent.com%2Flinux-find-command-with-practical-examples%2F&amp;linkname=Linux%20Find%20command%20%E2%80%93%20with%20Practical%20examples" title="Mastodon" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_email" href="https://www.addtoany.com/add_to/email?linkurl=https%3A%2F%2Flinuxcent.com%2Flinux-find-command-with-practical-examples%2F&amp;linkname=Linux%20Find%20command%20%E2%80%93%20with%20Practical%20examples" title="Email" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_whatsapp" href="https://www.addtoany.com/add_to/whatsapp?linkurl=https%3A%2F%2Flinuxcent.com%2Flinux-find-command-with-practical-examples%2F&amp;linkname=Linux%20Find%20command%20%E2%80%93%20with%20Practical%20examples" title="WhatsApp" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Flinuxcent.com%2Flinux-find-command-with-practical-examples%2F&amp;linkname=Linux%20Find%20command%20%E2%80%93%20with%20Practical%20examples" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_x" href="https://www.addtoany.com/add_to/x?linkurl=https%3A%2F%2Flinuxcent.com%2Flinux-find-command-with-practical-examples%2F&amp;linkname=Linux%20Find%20command%20%E2%80%93%20with%20Practical%20examples" title="X" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Flinuxcent.com%2Flinux-find-command-with-practical-examples%2F&amp;linkname=Linux%20Find%20command%20%E2%80%93%20with%20Practical%20examples" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_copy_link" href="https://www.addtoany.com/add_to/copy_link?linkurl=https%3A%2F%2Flinuxcent.com%2Flinux-find-command-with-practical-examples%2F&amp;linkname=Linux%20Find%20command%20%E2%80%93%20with%20Practical%20examples" title="Copy Link" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Flinuxcent.com%2Flinux-find-command-with-practical-examples%2F&#038;title=Linux%20Find%20command%20%E2%80%93%20with%20Practical%20examples" data-a2a-url="https://linuxcent.com/linux-find-command-with-practical-examples/" data-a2a-title="Linux Find command – with Practical examples"></a></p><p>The post <a href="https://linuxcent.com/linux-find-command-with-practical-examples/">Linux Find command &#8211; with Practical examples</a> appeared first on <a href="https://linuxcent.com">Linuxcent</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://linuxcent.com/linux-find-command-with-practical-examples/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">112</post-id>	</item>
		<item>
		<title>How to use grep command in Linux and Unix</title>
		<link>https://linuxcent.com/grep-command-linux/</link>
					<comments>https://linuxcent.com/grep-command-linux/#respond</comments>
		
		<dc:creator><![CDATA[Vamshi Krishna Santhapuri]]></dc:creator>
		<pubDate>Wed, 01 Mar 2023 10:22:39 +0000</pubDate>
				<category><![CDATA[Commands]]></category>
		<guid isPermaLink="false">https://linuxcent.com/?p=13</guid>

					<description><![CDATA[<p><span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> 6</span> <span class="rt-label rt-postfix">minutes</span></span>The grep command is one of the most essential commands in Unix/Linux ecosystem, It is used to extract match and find the occurrence of string literals and patterns among the text files. In this section we will focus on the important scenarios and provide the realtime explanation about the Various Grep command options offered in ... <a title="How to use grep command in Linux and Unix" class="read-more" href="https://linuxcent.com/grep-command-linux/" aria-label="Read more about How to use grep command in Linux and Unix">Read more</a></p>
<p>The post <a href="https://linuxcent.com/grep-command-linux/">How to use grep command in Linux and Unix</a> appeared first on <a href="https://linuxcent.com">Linuxcent</a>.</p>
]]></description>
										<content:encoded><![CDATA[<span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> 6</span> <span class="rt-label rt-postfix">minutes</span></span><p>The grep command is one of the most essential commands in Unix/Linux ecosystem, It is used to extract match and find the occurrence of string literals and patterns among the text files.</p>
<p>In this section we will focus on the important scenarios and provide the realtime explanation about the Various Grep command options offered in linux command line.</p>
<p>We now have a text file with Following content.</p>
<p>Below is the content of the file called <code>intro.txt</code>.</p>
<pre>[vamshi@linuxcent grep]$ cat intro.txt
the first line is in lower case
THE SECOND LINE IS IN UPPER CASE


There following are Most popular Linux server Distributions:
1) Redhat Enterprise Linux
2) Ubuntu
3) Centos
4) Debian
5) SUSE Linux Enterprise Server
This is a Demonstration of Linux grep command</pre>
<p>Let’s start with search of a string pattern in the given file</p>
<p>The <code>grep</code> command sample search syntax is</p>
<pre>$ grep “string pattern” &lt;filename&gt;</pre>
<pre>$ cat &lt; filename | * &gt; | grep "string pattern"</pre>
<p>Lets see the Demonstration</p>
<pre>[vamshi@linuxcent grep]$ grep "Linux" intro.txt
There following are Most popular Linux server Distributions:
1) Redhat Enterprise Linux
5) SUSE Linux Enterprise Server
This is a Demonstration of Linux grep command</pre>
<p>Searching for a pattern on multiple files using grep command</p>
<p>Lets see the Demonstration</p>
<pre class="lang:default decode:true ">[vamshi@linuxcent grep]$ grep "Linux" intro.txt intro-demo.txt
intro.txt:There following are Most popular Linux server Distributions:
intro.txt:1) Redhat Enterprise Linux
intro.txt:5) SUSE Linux Enterprise Server
intro.txt:This is a Demonstration of Linux grep command
intro-demo.txt:There following are Most popular Linux server Distributions:
intro-demo.txt:1) Redhat Enterprise Linux
intro-demo.txt:5) SUSE Linux Enterprise Server
intro-demo.txt:This is a Demonstration of Linux grep command</pre>
<p>&nbsp;</p>
<h2>How to print the sequence number of matched pattern in file using Grep command in Linux?</h2>
<p>Print the sequence number of lines that contain the matched string pattern can be achieved using <code>-n</code> Option:</p>
<pre>[vamshi@linuxcent grep]$ grep -n "Linux" intro.txt
4:There following are Most popular Linux server Distributions:
5:1) Redhat Enterprise Linux
9:5) SUSE Linux Enterprise Server
11:This is a Demonstration of Linux grep command</pre>
<p>The <code>-b</code> Option prints the subsequent starting offset index of the matching word from the lines within the given filename.</p>
<pre>[vamshi@linuxcent grep]$ grep -b "Linux" intro.txt
66:There following are Most popular Linux server Distributions:
127:1) Redhat Enterprise Linux
184:5) SUSE Linux Enterprise Server
217:This is a Demonstration of Linux grep command

</pre>
<p>So far we have seen only the matching string pattern, but if you want to find the occurance of particular word then use grep <code>-w</code> Option</p>
<p>Lets us see the Demonstration below:</p>
<pre>[vamshi@linuxcent grep]$ grep -w "Cent" intro.txt


</pre>
<p>And As expected here we have not seen any occurrence of the word Cent from the file although the word Centos was present, But it didnt match because we used <code>-w</code> option to match the word Cent.</p>
<p>But when we grep for the Word Linux then we can see the exact occurrence of the word and the matching lines are printed.</p>
<pre>[vamshi@linuxcent grep]$ grep -w "Linux" intro.txt
There following are Most popular Linux server Distributions:
1) Redhat Enterprise Linux
5) SUSE Linux Enterprise Server
This is a Demonstration of Linux grep command</pre>
<p>This can be used in conjunction with <code>-o</code> prints only completely matched word string pattern.</p>
<pre>[vamshi@linuxcent grep]$ grep -w -o "Linux" intro.txt
Linux
Linux
Linux
Linux

</pre>
<h2>How to use the Invert Option in Linux grep command</h2>
<p>The <code>-v</code> option prints all the lines not matching the given string pattern.</p>
<pre>[vamshi@linuxcent grep]$ grep -v "Linux" intro.txt
the first line is in lower case
THE SECOND LINE IS IN UPPER CASE


2) Ubuntu
3) Centos
4) Debian</pre>
<p>&nbsp;</p>
<p>How to print the names of all the files matching the string pattern using Linux Grep command.</p>
<p>Using the -l Option of grep command will print all the file names containing the matching string pattern/string literal</p>
<pre>[vamshi@node02 grep]$ grep -l Linux *
intro-demo.txt
intro.txt</pre>
<h2><b>How to get the number of Count Matches using Grep command ?<br />
</b></h2>
<p>In Linux Grep command we can use the Option <code>-c</code> to get the total occurance Count of the matching pattern/string</p>
<p>Lets see the Demonstration below</p>
<pre>[vamshi@linuxcent grep]$ grep -c "Linux" intro.txt
4</pre>
<h2><b>How to Exclude specific Directories while searching with grep command ?</b></h2>
<p>The <code>--exclude-dir=&quot;Some Directory name&quot;</code> options skips the contents of the mention directory Lets see the Demonstration:</p>
<pre>$ grep -w -E "data" * -R --exclude-dir="backup" --exclude-dir="adb-fastboot" --exclude-dir="IntelliJ-IDEA"</pre>
<h2><b>How to use Linux Grep commmand to ignore the case  OR perform Case Insensitive search ? </b></h2>
<p>Linux Grep Command offers the <code>-i</code> to skip the case and perform the search.<b><br />
</b></p>
<pre>[vamshi@linuxcent grep]$ grep -i Cent intro.txt
3)Centos</pre>
<p>Lets search for the Work Upper from the file with <code>-i</code> option</p>
<pre>[vamshi@linuxcent grep]$ grep Upper -i intro-demo.txt
THE SECOND LINE IS IN UPPER CASE
</pre>
<h2>How to Grep for the lines before and After the pattern occurrence in a file</h2>
<p>We can use the below options in Linux Grep command to extract the N number of lines matching the containing pattern before/After from the given file.. Lets look at the Options in detail</p>
<p>Generic Syntax:</p>
<pre>grep -&lt;A|B|C&gt; “string pattern” filename*</pre>
<p>Lets see the Demonstration as follows:</p>
<p><code>-A</code>: Prints N number of lines After the pattern match and the line containing the match</p>
<pre>[vamshi@linuxcent grep]$  grep -A2 docker /etc/passwd
dockerroot:x:996:992:Docker User:/var/lib/docker:/sbin/nologin
mysql:x:27:27:MariaDB Server:/var/lib/mysql:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin

</pre>
<p><code>-B</code>: Prints N number of lines Before the pattern match and the line containing the match</p>
<pre>[vamshi@linuxcent grep]$  grep -B2 docker /etc/passwd
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
builduser1:x:1002:1002::/home/builduser1:/bin/bash
dockerroot:x:996:992:Docker User:/var/lib/docker:/sbin/nologin</pre>
<p><code>-C</code>: Prints the line Containing the pattern and the N number of lines Before and After</p>
<pre>[vamshi@linuxcent grep]$ grep -C2 docker /etc/passwd
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
builduser1:x:1002:1002::/home/builduser1:/bin/bash
dockerroot:x:996:992:Docker User:/var/lib/docker:/sbin/nologin
mysql:x:27:27:MariaDB Server:/var/lib/mysql:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin</pre>
<h2>Linux Grep command using the Regular Expression (regex) search pattern</h2>
<h2>How to use the Special Meta-characters in Grep Command</h2>
<p>The Special Meta-Character <code>^</code> (caret) symbol to match expression at the start of a line.<br />
Practical examples of grep command using meta-characters are as follows:</p>
<pre>[vamshi@linuxcent grep]$ grep ^root /etc/services
rootd           1094/tcp                # ROOTD
rootd           1094/udp                # ROOTD</pre>
<p><code>$</code> (dollar) symbol to match expression at the end of a line</p>
<pre>[vamshi@linuxcent grep]$ grep "bash$" /etc/passwd
root:x:0:0:root:/root:/bin/bash
vagrant:x:1000:1000:vagrant:/home/vagrant:/bin/bash
vamshi:x:1001:1001::/home/vamshi:/bin/bash
jenkins:x:997:994:Jenkins Automation Server:/var/lib/jenkins:/bin/bash
builduser1:x:1002:1002::/home/builduser1:/bin/bash
linuxcent:x:1003:1004::/home/linuxcent:/bin/bash</pre>
<p>Another Bonus regex for evading Empty lines from a text file using the Meta-characters <code>^</code> Carat and <code>$</code> Dollar Symbols.</p>
<pre>[vamshi@node02 grep]$ grep -Ev "^$" intro.txt
the first line is in lower case
THE SECOND LINE IS IN UPPER CASE
There following are Most popular Linux server Distributions:
1) Redhat Enterprise Linux
2) Ubuntu
3) Centos
4) Debian
5) SUSE Linux Enterprise Server
This is a Demonstration of Linux grep command</pre>
<p>As the result of the above command observed Empty lines in our text file are now excluded with the inverted matching of Empty line pattern expression.</p>
<h2>Digit Matching operation using Linux Grep Command</h2>
<p>The Grep command Option <code>-P</code> offers the perl-regex pattern matching to perform some of the tricky pattern matching conditions, Lets see the Demonstration.</p>
<pre>[vamshi@linuxcent grep]$ grep -P "[\W][\d][\d]/" /etc/services</pre>
<p>Now we Demonstrate Numerical pattern matching in the following ways to match the exact occurrence of IPv4 address</p>
<pre>[vamshi@linuxcent grep]$ ip a |grep -E "[0-9].[0-9].[0-9].[0-9]"
inet 127.0.0.1/8 scope host lo
inet 10.100.0.20/24 brd 10.100.0.255 scope global noprefixroute eth1</pre>
<p>The similar result can be extracted using <code>-P</code>, Demonstrated as below:</p>
<pre>[vamshi@linuxcent grep]$ ip a  | grep -P "[\d].[\d].[\d].[\d]"
inet 127.0.0.1/8 scope host lo
inet 10.100.0.20/24 brd 10.100.0.255 scope global noprefixroute eth1</pre>
<p>Highlighting the Search patterns with Color codes</p>
<p>If you want to highlight the search pattern from the output we can make use of Color code Option is grep</p>
<pre>[vamshi@linuxcent ~]$ ps -ef |grep java --color=yes</pre>
<p>&nbsp;</p>
<p>grep command and the Meta-characters with practical examples</p>
<p>In the Extended Regular Expression the metacharacters ?, \+, \{,  \|, \(, and \) enhances and takes the search string to manifest into a rich pattern</p>
<p>The square brackets [/code][ ][/code] includes a list of characters and it matches a single character in the list. Within the bracket, we can specify a  range, like [a-z] [0-9] [abcd], But it only matches a single character in the give list range.<br />
The brackets can contain the carat <code>^</code> or the <code>$</code> symbols and can be globbed with the wildcard characters for finding the repetitive pattern.</p>
<p>Here we shall see the demonstration of a few metacharacters conjunction into a single grep command</p>
<p>Using the Infix Operator <code>|</code> with the meta-characters</p>
<pre>$ dmesg -H | egrep '(s|h)d[a-z]'</pre>
<p>A quick practical look at the dmesg to find about the errors and warnings using grep command.</p>
<p>$ dmesg -H | grep -Ei &#8220;error|warn&#8221;</p>
<p>How to find the exact work match for the word error or err with a blank white space at the start of the word from dmesg?<br />
$ dmesg -H | grep -Ei &#8220;(er)[r]{1,2}(or)&#8221;<br />
$ dmesg -H | grep -Ei &#8220;(\We)[r]+(or)|(\Werr)&#8221;</p>
<p>Explanation: The grep search metacharacter regular expression matches the occurring of the string literals “error” with the minimum 1 time occurrence (error) of literal r and maximum 2 times.</p>
<p>The output only prints lines containing the word “error“ in a case insensitive grep search.</p>
<p>&nbsp;</p>
<p>Another great practical example here we apply the same logic to enhance the metacharacter regex pattern to search for the occurrence of error with but without a trailing colon “:” symbol</p>
<p>dmesg -H | grep -Ei &#8220;(error)[:]{0}&#8221;</p>
<p>&nbsp;</p>
<p><a class="a2a_button_mastodon" href="https://www.addtoany.com/add_to/mastodon?linkurl=https%3A%2F%2Flinuxcent.com%2Fgrep-command-linux%2F&amp;linkname=How%20to%20use%20grep%20command%20in%20Linux%20and%20Unix" title="Mastodon" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_email" href="https://www.addtoany.com/add_to/email?linkurl=https%3A%2F%2Flinuxcent.com%2Fgrep-command-linux%2F&amp;linkname=How%20to%20use%20grep%20command%20in%20Linux%20and%20Unix" title="Email" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_whatsapp" href="https://www.addtoany.com/add_to/whatsapp?linkurl=https%3A%2F%2Flinuxcent.com%2Fgrep-command-linux%2F&amp;linkname=How%20to%20use%20grep%20command%20in%20Linux%20and%20Unix" title="WhatsApp" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Flinuxcent.com%2Fgrep-command-linux%2F&amp;linkname=How%20to%20use%20grep%20command%20in%20Linux%20and%20Unix" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_x" href="https://www.addtoany.com/add_to/x?linkurl=https%3A%2F%2Flinuxcent.com%2Fgrep-command-linux%2F&amp;linkname=How%20to%20use%20grep%20command%20in%20Linux%20and%20Unix" title="X" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Flinuxcent.com%2Fgrep-command-linux%2F&amp;linkname=How%20to%20use%20grep%20command%20in%20Linux%20and%20Unix" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_copy_link" href="https://www.addtoany.com/add_to/copy_link?linkurl=https%3A%2F%2Flinuxcent.com%2Fgrep-command-linux%2F&amp;linkname=How%20to%20use%20grep%20command%20in%20Linux%20and%20Unix" title="Copy Link" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Flinuxcent.com%2Fgrep-command-linux%2F&#038;title=How%20to%20use%20grep%20command%20in%20Linux%20and%20Unix" data-a2a-url="https://linuxcent.com/grep-command-linux/" data-a2a-title="How to use grep command in Linux and Unix"></a></p><p>The post <a href="https://linuxcent.com/grep-command-linux/">How to use grep command in Linux and Unix</a> appeared first on <a href="https://linuxcent.com">Linuxcent</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://linuxcent.com/grep-command-linux/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">13</post-id>	</item>
		<item>
		<title>Change file(s) and Directory/Folder ownership &#8211; chmod command in Linux</title>
		<link>https://linuxcent.com/change-files-and-directory-folder-ownership-chown-command-in-linux/</link>
					<comments>https://linuxcent.com/change-files-and-directory-folder-ownership-chown-command-in-linux/#respond</comments>
		
		<dc:creator><![CDATA[Vamshi Krishna Santhapuri]]></dc:creator>
		<pubDate>Tue, 28 Feb 2023 18:53:32 +0000</pubDate>
				<category><![CDATA[Commands]]></category>
		<guid isPermaLink="false">https://linuxcent.com/?p=97</guid>

					<description><![CDATA[<p><span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> 3</span> <span class="rt-label rt-postfix">minutes</span></span>The Linux command utility is used to set permissions on files and directories The command , or Change Mode, is widely used to modify the access permissions of files and directories, This facilitates the users to keep the data secure and properly organized. There are three types the file permissions can be modified using chmod ... <a title="Change file(s) and Directory/Folder ownership &#8211; chmod command in Linux" class="read-more" href="https://linuxcent.com/change-files-and-directory-folder-ownership-chown-command-in-linux/" aria-label="Read more about Change file(s) and Directory/Folder ownership &#8211; chmod command in Linux">Read more</a></p>
<p>The post <a href="https://linuxcent.com/change-files-and-directory-folder-ownership-chown-command-in-linux/">Change file(s) and Directory/Folder ownership &#8211; chmod command in Linux</a> appeared first on <a href="https://linuxcent.com">Linuxcent</a>.</p>
]]></description>
										<content:encoded><![CDATA[<span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> 3</span> <span class="rt-label rt-postfix">minutes</span></span><p>The Linux command utility <code>chmod</code> is used to set permissions on files and directories</p>
<p>The command <code>&lt;b&gt;chmod&lt;/b&gt;</code>, or <b>Change Mode</b>, is widely used to modify the access permissions of files and directories, This facilitates the users to keep the data secure and properly organized.<br />
There are three types the file permissions can be modified using chmod command:</p>
<p>1) Symblolic Notation</p>
<p>2) Octal Notation</p>
<p>3) Reference operator</p>
<p>The Owners, Groups and Others have different permissions to access a particular file.<br />
Lets see the Sample syntax of <code>chmod</code></p>
<pre>$ chmod [option] [mode] &lt; file | directory&gt;</pre>
<p>The <code>Users categories</code> are symbolically represented as</p>
<p><b><code>-u</code></b> is used for the User/Owner</p>
<p><b><code>g</code></b> is used for the Group</p>
<p><b><code>o</code></b> is used for the Others</p>
<p>The <code>Permission modes</code> used to modify the Read, Write and Execute permissions respectively on a file or Directory and are symbolically represented as follows</p>
<p><code>r</code> is for Read permission</p>
<p><code>w</code> is for Write permission</p>
<p><code>x</code> is for Execute permission</p>
<p>The Octal notation is simpler interms of representation and execution with <code>r=4</code> <code>w=2</code> <code>x=1</code> total adding up to numerical aggregate value of 7 taking the place holders of <code>Owner</code>(<b><code>-u</code></b>) <code>Group</code>(<b><code>-g</code></b>) <code>Others</code>(<b><code>-o</code></b>) respectively.</p>
<p>Lets see the file permissions for a sample file with complete access to every user category i.e owner, group and others, Meaning that any person who has access to the file can modify,execute(run) or delete the newfile.txt</p>
<pre>[vamshi@node02 linuxcent]$ ls -l file.txt
-rwxrwxrwx. 1 vamshi vamshi 3 Apr 10 19:13 file.txt</pre>
<p>From the above listed permissions we would like to release the &#8220;others&#8221; from writing this file but only limit them to read it.</p>
<p>The command will be to delete the Write permissions from others:</p>
<pre>[vamshi@linuxcent ~]$ $ chmod o-w file.txt
[vamshi@linuxcent ~]$ ls -l file.txt
-rwxrwxr-x. 1 vamshi vamshi 3 Apr 10 19:13 file.txt</pre>
<p>We use the <code>+</code> and <code>-</code> operators to provide the Read,Write and Execute permissions to user categories, It’s Demonstrated as follows:</p>
<pre>[vamshi@node02 linuxcent]$ chmod og-rw file.txt
[vamshi@node02 linuxcent]$ ls -l file.txt
-rwx------. 1 vamshi vamshi 3 Apr 10 20:23 file.txt</pre>
<p>Combining options such read operation for other and group, write for group and execute permission being removed for owner.</p>
<pre>[vamshi@node02 linuxcent]$ chmod og+r,g+w,u-x file.txt</pre>
<pre>[vamshi@node02 linuxcent]$ ls -l file.txt
-rw-rw-r--. 1 vamshi vamshi 3 Apr 10 20:23 file.txt</pre>
<p>Creating a new file newfile.txt and working with it</p>
<pre>[vamshi@node02 linuxcent]$ echo "Welcome to LinuxCent" &gt; newfile.txt</pre>
<p>Here are the file’s permissions when it’s newly created. It is resultant of the umask</p>
<p>Lets look at a Linux practical example to setup only <code>execute</code> permission for all the user categories</p>
<pre>$ chmod +x  /etc/profile.d/java-path.sh</pre>
<h2>Listing out the System defined Default umask in Symbolic notation.</h2>
<p>The Default Umask permissions can be demonstrated as below:</p>
<pre>[vamshi@node02 linuxcent]$ umask -S
u=rwx,g=rwx,o=rx</pre>
<p>Umask in Octal Notation as below:</p>
<pre>[vamshi@node02 linuxcent]$ umask
0002</pre>
<p>Now the new lets see the file permissions:</p>
<pre>[vamshi@node02 linuxcent]$ ls -l newfile.txt
-rw-rw-r--. 1 vamshi vamshi 21 Apr 10 19:49 newfile.txt</pre>
<p>This is the inverse notation of the umask Octal value(002) set at the system wide and our file has the 664 Octal Notation.</p>
<p>The Octal mode of Permissions</p>
<p>These permissions carry a numerical value all adding up to a sum of 4 and categorized as follows:</p>
<code>r=4</code>
<code>w=2</code>
<code>x=1</code>
<p>For Example chmod 754 file1.txt</p>
<pre>[vamshi@node02 linuxcent]$ ls -lth newfile.txt
-rwxr-xr--. 1 vamshi vamshi 3 Apr 10 19:13 newfile.txt</pre>
<h2>How to apply reference permissions in Linux using chmod ?</h2>
<p>We shall be using the option <code>&lt;b&gt;--reference</code></b> which takes the reference from the existing file and applies the permission</p>
<p>Lets see the demonstration below:</p>
<pre>vamshi@linuxcent ~]$ ls -l anotherfile.txt
-rwxrwx---. 1 vamshi vamshi  33 Apr 8 19:52 anotherfile.txt
</pre>
<pre>vamshi@linuxcent ~]$ chmod --reference=anotherfile.txt newfile.txt</pre>
<pre>[vamshi@linuxcent ~ ]$ ls -l newfile.txt 
-rwxrwx---. 1 vamshi vamshi 21 Apr 10 19:49 newfile.txt</pre>
<p>With this reference operator, the nexfile.txt permissions are modified identical to anotherfile.txt</p>
<p>&nbsp;</p>
<p><a class="a2a_button_mastodon" href="https://www.addtoany.com/add_to/mastodon?linkurl=https%3A%2F%2Flinuxcent.com%2Fchange-files-and-directory-folder-ownership-chown-command-in-linux%2F&amp;linkname=Change%20file%28s%29%20and%20Directory%2FFolder%20ownership%20%E2%80%93%20chmod%20command%20in%20Linux" title="Mastodon" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_email" href="https://www.addtoany.com/add_to/email?linkurl=https%3A%2F%2Flinuxcent.com%2Fchange-files-and-directory-folder-ownership-chown-command-in-linux%2F&amp;linkname=Change%20file%28s%29%20and%20Directory%2FFolder%20ownership%20%E2%80%93%20chmod%20command%20in%20Linux" title="Email" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_whatsapp" href="https://www.addtoany.com/add_to/whatsapp?linkurl=https%3A%2F%2Flinuxcent.com%2Fchange-files-and-directory-folder-ownership-chown-command-in-linux%2F&amp;linkname=Change%20file%28s%29%20and%20Directory%2FFolder%20ownership%20%E2%80%93%20chmod%20command%20in%20Linux" title="WhatsApp" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Flinuxcent.com%2Fchange-files-and-directory-folder-ownership-chown-command-in-linux%2F&amp;linkname=Change%20file%28s%29%20and%20Directory%2FFolder%20ownership%20%E2%80%93%20chmod%20command%20in%20Linux" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_x" href="https://www.addtoany.com/add_to/x?linkurl=https%3A%2F%2Flinuxcent.com%2Fchange-files-and-directory-folder-ownership-chown-command-in-linux%2F&amp;linkname=Change%20file%28s%29%20and%20Directory%2FFolder%20ownership%20%E2%80%93%20chmod%20command%20in%20Linux" title="X" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Flinuxcent.com%2Fchange-files-and-directory-folder-ownership-chown-command-in-linux%2F&amp;linkname=Change%20file%28s%29%20and%20Directory%2FFolder%20ownership%20%E2%80%93%20chmod%20command%20in%20Linux" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_copy_link" href="https://www.addtoany.com/add_to/copy_link?linkurl=https%3A%2F%2Flinuxcent.com%2Fchange-files-and-directory-folder-ownership-chown-command-in-linux%2F&amp;linkname=Change%20file%28s%29%20and%20Directory%2FFolder%20ownership%20%E2%80%93%20chmod%20command%20in%20Linux" title="Copy Link" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Flinuxcent.com%2Fchange-files-and-directory-folder-ownership-chown-command-in-linux%2F&#038;title=Change%20file%28s%29%20and%20Directory%2FFolder%20ownership%20%E2%80%93%20chmod%20command%20in%20Linux" data-a2a-url="https://linuxcent.com/change-files-and-directory-folder-ownership-chown-command-in-linux/" data-a2a-title="Change file(s) and Directory/Folder ownership – chmod command in Linux"></a></p><p>The post <a href="https://linuxcent.com/change-files-and-directory-folder-ownership-chown-command-in-linux/">Change file(s) and Directory/Folder ownership &#8211; chmod command in Linux</a> appeared first on <a href="https://linuxcent.com">Linuxcent</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://linuxcent.com/change-files-and-directory-folder-ownership-chown-command-in-linux/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">97</post-id>	</item>
		<item>
		<title>Linux Commands Cheat Sheet</title>
		<link>https://linuxcent.com/linux-commands-cheat-sheet/</link>
					<comments>https://linuxcent.com/linux-commands-cheat-sheet/#respond</comments>
		
		<dc:creator><![CDATA[Vamshi Krishna Santhapuri]]></dc:creator>
		<pubDate>Thu, 11 Nov 2021 10:33:15 +0000</pubDate>
				<category><![CDATA[Commands]]></category>
		<guid isPermaLink="false">https://linuxcent.com/?p=975</guid>

					<description><![CDATA[<p><span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> 17</span> <span class="rt-label rt-postfix">minutes</span></span>Do you want to learn the Linux commands? If yes, then you are in the right place. There are uncountable commands in Linux. Generally, we use some of the Linux commands from the Linux commands cheat sheet regularly to perform the common tasks. pythonarray.com is a free Python tutorial website for people who want to ... <a title="Linux Commands Cheat Sheet" class="read-more" href="https://linuxcent.com/linux-commands-cheat-sheet/" aria-label="Read more about Linux Commands Cheat Sheet">Read more</a></p>
<p>The post <a href="https://linuxcent.com/linux-commands-cheat-sheet/">Linux Commands Cheat Sheet</a> appeared first on <a href="https://linuxcent.com">Linuxcent</a>.</p>
]]></description>
										<content:encoded><![CDATA[<span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> 17</span> <span class="rt-label rt-postfix">minutes</span></span><p>Do you want to learn the Linux commands? If yes, then you are in the right place. There are uncountable commands in Linux. Generally, we use some of the Linux commands from the Linux commands cheat sheet regularly to perform the common tasks.</p>
<p><a href="https://pythonarray.com/">pythonarray.com</a> is a free Python tutorial website for people who want to learn Python, fast.</p>
<ul>
<li><a href="#Basic_Linux_Commands">Basic Linux Commands</a></li>
<li><a href="#File_Permission_Commands">File Permission Commands</a></li>
<li><a href="#Environment_Variables_Command">Environment Variables Command</a></li>
<li><a href="#User_Management_Commands_of_Linux">User Management Commands of Linux</a></li>
<li><a href="#Networking_Commands">Networking Commands</a></li>
<li><a href="#Process_Commands">Process Commands</a></li>
<li><a href="#VI_Editing_Commands">VI Editing Commands</a></li>
<li><a href="#Other_Linux_Commands">Other Linux Commands</a></li>
</ul>
<p>You can also learn <a href="https://sheetstips.com/google-sheets-tips/">Google Sheets Tips</a> – New Google Spreadsheet Hacks, Tricks with Examples</p>
<h2>Types of Linux Commands</h2>
<p>All the Linux commands are categorized into 7 different types. They are Basic Linux commands, File permission commands, Environment variables commands, User management commands, Networking commands, Process commands, VI Editing commands, Other Commands.</p>
<p>We are giving a detailed explanation for each and every Linux command with their examples for easy learning in the below sections. Have a look at them and follow them. Check the actual description of each Linux command in their manual page.</p>
<h3><a id="Basic_Linux_Commands"></a>Basic Linux Commands</h3>
<ul>
<li><strong>ls command:</strong></li>
</ul>
<p>It is used to list all files and directories of a directory. The &#8216;-l&#8217; option gives the long listing format. Its syntax is $ ls [options] [file|dir]</p>
<p><i>Example:</i> $ ls -l samplefile</p>
<ul>
<li><strong>ls-R command:</strong></li>
</ul>
<p>It gives the lists files in subdirectories. List recursively directory tree and syntax is $ ls -R [options] [file|dir]</p>
<p><i>Example:</i> $ ls -R samplefile</p>
<ul>
<li><strong>ls -a Command:</strong></li>
</ul>
<p>It lists all files including hidden files starting with&#8217;.&#8217; Its syntax is $ ls -a [options] [file|dir]</p>
<ul>
<li><strong>ls -al Command: </strong></li>
</ul>
<p>It lists all files details and directories with detailed information like permissions, size, owner, etc. Syntax is $ ls -al [options] [file|dir]</p>
<ul>
<li><strong>cd or cd ~ Command:</strong></li>
</ul>
<p>This command will navigate to the home directory or change the directory. Its syntax is $ cd [directory]</p>
<p><i>Example:</i> $ cd Directory1</p>
<ul>
<li><strong>cd .. Command:</strong></li>
</ul>
<p>It moves one level up. Syntax is $ cd . . [directory]</p>
<ul>
<li><strong>cd Command:</strong></li>
</ul>
<p>Use this command to change to a particular directory. Its syntax is $ cd [directory]</p>
<p><i>Example:</i> $ cd directory1</p>
<ul>
<li><strong>cd / Command:</strong></li>
</ul>
<p>This command will move to the root directory. Syntax is $ cd /</p>
<ul>
<li><strong>cat filename Command:</strong></li>
</ul>
<p>Create a new file using this command in Linux. Its syntax is $ cat filename.</p>
<p><i>Example:</i> $ cat filename1</p>
<ul>
<li><strong>cat filename Command:</strong></li>
</ul>
<p>It displays the content in that particular file. The syntax is $ cat filename.</p>
<p><i>Example:</i> $ cat filename1.</p>
<ul>
<li><strong>cat file1 file2 file3 Command:</strong></li>
</ul>
<p>It combines two files namely file1 and file2 and stores the output in a new file called file3. Its syntax is $ cat file1 file2 file3.</p>
<p><i>Example:</i> $ cat add multiply arithmetic.</p>
<ul>
<li><strong>mv file &#8220;new file path&#8221; Command:</strong></li>
</ul>
<p>It moves the files to the new location. Syntax is $ mv file &#8220;new file path&#8221;.</p>
<p><i>Example:</i> $ mv add &#8220;E:/Arithmeticopeartions/&#8221;.</p>
<ul>
<li><strong>mv filename new_file_name Command:</strong></li>
</ul>
<p>It renames or changes the file name to a new file name. Syntax is $ mv filename new_file_name.</p>
<p><i>Example:</i> $ mv add sum</p>
<ul>
<li><strong>sudo Command:</strong></li>
</ul>
<p>sudo command allows a permitted user to run a command as root or another user. It runs commands in superuser mode. The syntax is $ sudo filename option</p>
<p><i>Example:</i> $ sudo apt update</p>
<ul>
<li><strong>rm Command:</strong></li>
</ul>
<p>It is used to remove the files or directories. Syntax is $ rm filename or $ rm directory</p>
<p><i>Examples:</i> $ rm sum and $ rm mydrive</p>
<ul>
<li><strong>man Command:</strong></li>
</ul>
<p>It is used to view the online reference manual pages for the commands or programs. It provides the help information of any commands. Its syntax is $ man commandname</p>
<p><i>Example:</i> $ man cd</p>
<ul>
<li><strong>history Command:</strong></li>
</ul>
<p>It produces the list of previously used commands and gets the all past commands types in the current terminal session. The syntax is $ history</p>
<ul>
<li><strong>clear Command:</strong></li>
</ul>
<p>clear command is helpful to clear the terminal screen. The syntax is $ clear</p>
<ul>
<li><strong>mkdir directoryname Command:</strong></li>
</ul>
<p>It creates a new directory in the present working directory or at any specific path. Syntax is $ mkdir directoryname</p>
<p><i>Example:</i> $ mkdir new_directory</p>
<p>$ mkdir -p new_directory: Here -p option is used to override the already available directory.</p>
<ul>
<li><strong>rmdir Command:</strong></li>
</ul>
<p>It helps to remove/ delete the empty directories. Syntax is $ rmdir [directory_name]</p>
<p><i>Example:</i> $ rmdir new_directory</p>
<ul>
<li><strong>mv Command:</strong></li>
</ul>
<p>It is helpful to rename files or directories. mv command also moves a file or a directory to another location in the directory structure. Its syntax is $ mv file1 file2</p>
<p><i>Example:</i> $ mv add sum</p>
<ul>
<li><strong>pr -x Command:</strong></li>
</ul>
<p>It divides the file into x columns. Syntax is $ pr -x filename.</p>
<p><i>Example:</i> $ pr -5 add</p>
<ul>
<li><strong>pr -h Command:</strong></li>
</ul>
<p>It is useful to assign a header to the file. Syntax is $ pr -h filename</p>
<p><i>Example:</i> $ pr -h sum</p>
<ul>
<li><strong>pr -n Command:</strong></li>
</ul>
<p>This command denotes the file with the line numbers. Its syntax is $ pr -n file</p>
<p><i>Example:</i> $ pr -n sum</p>
<ul>
<li><strong>lp -nc , lpr c Command:</strong></li>
</ul>
<p>It prints the c number of copies of a file. lp stands for a line printer. Its syntax is $ lpr c filename</p>
<p><i>Example:</i> $ lpr 5 sum</p>
<ul>
<li><strong>lp -d lp -P Command:</strong></li>
</ul>
<p>It specifies the name of the printer. The syntax is $ lp -P</p>
<ul>
<li><strong>apt-get Command:</strong></li>
</ul>
<p>It is a powerful and free front end package manager for Debian/Ubuntu systems. It is used to install new software packages, remove available software packages, upgrade existing software packages, and upgrade the entire operating system. Its syntax is $ apt-get package</p>
<p><i>Example:</i> $ sudo apt-get update</p>
<ul>
<li><strong>mail -s &#8216;subject&#8217; -c &#8216;cc-address&#8217; -b &#8216;bcc-address&#8217; &#8216;to-address&#8217; Command:</strong></li>
</ul>
<p>It is a linux command used to send mail. Syntax is $ mail -s &#8216;subject&#8217; -c &#8216;cc-address&#8217; -b &#8216;bcc-address&#8217; &#8216;to-address&#8217;</p>
<p><i>Example:</i> $ mail -s &#8216;regarding_job&#8217; -c &#8216;add@gmail.com&#8217; -b &#8216;sum@gmail.com&#8217; &#8216;arithmetic@gmail.com&#8217;</p>
<ul>
<li><strong>mail -s &#8220;Subject&#8221; to-address &lt; Filename Command:</strong></li>
</ul>
<p>It is used to send an email with an attachment. Its syntax is $ mail -s &#8220;Subject&#8221; to-address &lt; Filename</p>
<p><i>Example:</i> $ mail -s &#8220;Addition of Numbers&#8221; sum@gmail.com &lt; Addition</p>
<h3><a id="File_Permission_Commands"></a>File Permission Commands</h3>
<ul>
<li><strong>ls-l Command:</strong></li>
</ul>
<p>Use this command to show file type and access permission of any particular file. Syntax is $ ls-l filename</p>
<p><i>Example:</i> $ ls-l sum</p>
<ul>
<li><strong>r Command:</strong></li>
</ul>
<p>It is used to give read permission to a file. The syntax is $ r filename.</p>
<p><i>Example:</i> $ r sum</p>
<ul>
<li><strong>w Command:</strong></li>
</ul>
<p>It gives write permission to the file. The syntax is $ w filename</p>
<p><i>Example:</i> $ w sum</p>
<ul>
<li><strong>x Command:</strong></li>
</ul>
<p>It is useful to provide execute permission to the file. Its syntax is $ x filename</p>
<p><i>Example:</i> $ x sum</p>
<ul>
<li><strong>-= Command:</strong></li>
</ul>
<p>This command is used when you want to give no permission to a file. Syntax is $ -= filename</p>
<p><i>Example:</i> $ -= file1</p>
<ul>
<li><strong>Chown user Command:</strong></li>
</ul>
<p>It is helpful to change the ownership of a file/directory. The syntax is $ chown user filename</p>
<p><i>Example:</i> $ chown user file1</p>
<ul>
<li><strong>Chown user:group filename Command:</strong></li>
</ul>
<p>It changes the user and group for a file or directory. Syntax is $ chown user:group filename</p>
<p><i>Example:</i> $ chown user:group sum</p>
<h3><a id="Environment_Variables_Command"></a>Environment Variables Command</h3>
<ul>
<li><strong>echo $VARIABLE Command:</strong></li>
</ul>
<p>It displays the value of a variable or prints a text of the line. Its syntax is echo [option] [string]</p>
<p><i>Example:</i> $ echo &#8220;Print this line&#8221; or $ echo $VARIABLE var1</p>
<ul>
<li><strong>env Command:</strong></li>
</ul>
<p>It lists all environment variables. The syntax is $ env</p>
<ul>
<li><strong>VARIABLE_NAME= variable_value Command:</strong></li>
</ul>
<p>It creates a new variable and assigns it a value. Syntax is $ VARIABLE_NAME= variable_value</p>
<p><i>Example:</i> $ My_Variable= 10</p>
<ul>
<li><strong>Unset Command:</strong></li>
</ul>
<p>It removes a variable. Syntax is $ Unset VARIABLE_NAME</p>
<p><i>Example:</i> $ Unset My_Variable</p>
<ul>
<li><strong>export Variable=value Command:</strong></li>
</ul>
<p>It is helpful to set the value of an environment variable. Syntax is $ export Variable=value</p>
<p><i>Example:</i> $ export Variable1=90</p>
<h3><a id="User_Management_Commands_of_Linux"></a>User Management Commands of Linux</h3>
<ul>
<li><strong>sudo adduser username Command:</strong></li>
</ul>
<p>It is used to create a username. The syntax is $ sudo adduser username</p>
<p><i>Example:</i> $ sudo dduser user1</p>
<ul>
<li><strong>sudo passwd -l &#8216;username&#8217; Command:</strong></li>
</ul>
<p>It is helpful to change the user password. Syntax is $ sudo passwd -l &#8216;username&#8217;</p>
<p><i>Example:</i> $ sudo passwd -l &#8216;user1&#8217;</p>
<ul>
<li><strong>sudo userdel -r &#8216;username&#8217; Command:</strong></li>
</ul>
<p>This command is used to add and delete users on Linux. Syntax is $ sudo userdel -r &#8216;username&#8217;</p>
<p><i>Example:</i> $ sudo userdel -r &#8216;user1&#8217;</p>
<ul>
<li><strong>finger Command:</strong></li>
</ul>
<p>It is a user information lookup command which provides details of all users logged in. The Syntax $ finger</p>
<ul>
<li><strong>finger username Command:</strong></li>
</ul>
<p>It gives the login details of that particular user. Syntax $ finger username</p>
<p><i>Example:</i> $ finger user1</p>
<h3><a id="Networking_Commands"></a>Networking Commands</h3>
<ul>
<li><strong>SSH username@ip-address or hostname Command:</strong></li>
</ul>
<p>You can log in to a remote Linux machine using SSH. The syntax is $ SSH username@ip-address or hostname</p>
<p><i>Example:</i> $ SSH user1@https:11//1001</p>
<ul>
<li><strong>Ping hostname=&#8221;&#8221; or =&#8221;&#8221; Command:</strong></li>
</ul>
<p>It is used for analyzing the network and host connections. Syntax is $ Ping hostname=&#8221;&#8221; or =&#8221;&#8221;</p>
<p><i>Example:</i> $ Ping hostname=&#8221;host1&#8243;</p>
<ul>
<li><strong>dir Command:</strong></li>
</ul>
<p>It displays all files in the current directory of a remote computer. The syntax is $ dir</p>
<ul>
<li><strong>cd &#8220;dirname&#8221; Command:</strong></li>
</ul>
<p>It changes the current directory to &#8220;dirname&#8221; on a remote computer. Syntax is $ cd &#8220;dirname&#8221;</p>
<p><i>Example:</i> $ cd &#8220;E&#8221;</p>
<ul>
<li><strong>put file Command:</strong></li>
</ul>
<p>It is helpful to upload the file from local to the remote computer. The syntax is $ put file</p>
<p><i>Example:</i> $ put sum</p>
<ul>
<li><strong>get file Command:</strong></li>
</ul>
<p>It is used to download the file from remote to the local computer. The syntax is $ get file</p>
<p><i>Example:</i> $ get add</p>
<ul>
<li><strong>quit Command:</strong></li>
</ul>
<p>It is used to logout from that network. The syntax is $ quit</p>
<h3><a id="Process_Commands"></a>Process Commands</h3>
<ul>
<li><strong>bg Command:</strong></li>
</ul>
<p>You can send a process to the background with this command. The syntax is $ bg processname</p>
<p><i>Example:</i> $ bg process1</p>
<ul>
<li><strong>fg Command:</strong></li>
</ul>
<p>To run a stopped process in the foreground. The syntax is $ fg processname.</p>
<p><i>Example:</i> $ fg process1</p>
<ul>
<li><strong>top Command:</strong></li>
</ul>
<p>It gives the details of all active processes in the directory. The syntax is $ top</p>
<ul>
<li><strong>ps Command:</strong></li>
</ul>
<p>It produces the status of processes running for a user. The syntax is $ ps username</p>
<p><i>Example:</i> $ ps user1</p>
<ul>
<li><strong>ps PID Command:</strong></li>
</ul>
<p>This command gives the status of a particular process. The syntax is $ ps PID processname</p>
<p><i>Example:</i> $ ps PID process1</p>
<ul>
<li><strong>pidof Command:</strong></li>
</ul>
<p>It gives the process id of a process. The syntax is $ pidof processname.</p>
<p><i>Example:</i> $ pidof process1</p>
<ul>
<li><strong>kill PID Command:</strong></li>
</ul>
<p>It kills a process. The syntax is $ kill PID processname</p>
<p><i>Example:</i> $ kill PID process1</p>
<ul>
<li><strong>nice Command:</strong></li>
</ul>
<p>It is used to start a process with the given priority. The syntax is $ nice processname.</p>
<p><i>Example:</i> $ nice process</p>
<ul>
<li><strong>renice Command:</strong></li>
</ul>
<p>It is used to change the priority of an already running process. The syntax is $ renice processname</p>
<p><i>Example:</i> $ renice process2</p>
<ul>
<li><strong>df Command:</strong></li>
</ul>
<p>It provides free hard disk space on your system. The syntax is $ df</p>
<ul>
<li><strong>free Command:</strong></li>
</ul>
<p>It gives free RAM space on your system. The syntax is $ free</p>
<h3><a id="VI_Editing_Commands"></a>VI Editing Commands</h3>
<ul>
<li><strong>i Command:</strong></li>
</ul>
<p>It inserts at the cursor i.e goes to insert mode. The syntax is $ i</p>
<ul>
<li><strong>a Command:</strong></li>
</ul>
<p>It is used to write after the cursor in insert mode. The syntax is $ a</p>
<ul>
<li><strong>A Command:</strong></li>
</ul>
<p>This command is used to write at the end of the line in insert mode. The syntax is $ A</p>
<ul>
<li><strong>ESC Command:</strong></li>
</ul>
<p>It is helpful to terminate insert mode. The syntax is $ ESC.</p>
<ul>
<li><strong>u Command:</strong></li>
</ul>
<p>It undoes the last change. The syntax is $ u.</p>
<ul>
<li><strong>U Command:</strong></li>
</ul>
<p>It undoes all changes to the entire line. The syntax is $ U</p>
<ul>
<li><strong>o Command:</strong></li>
</ul>
<p>It opens a new line in insert mode. The syntax is $ o</p>
<ul>
<li><strong>dd Command:</strong></li>
</ul>
<p>It deletes that particular line. The syntax is $ dd line number</p>
<p>Example: $ dd 25</p>
<ul>
<li><strong>3dd Command:</strong></li>
</ul>
<p>This command deletes 3 lines. The syntax is $ 3dd line number</p>
<p><i>Example:</i> $ 3dd 25</p>
<ul>
<li><strong>D Command:</strong></li>
</ul>
<p>It deletes the contents of a line after the cursor. The syntax is $ D</p>
<ul>
<li><strong>C Command:</strong></li>
</ul>
<p>It is used to delete the contents of a line after the cursor and insert new text. Press the ESC key to end the insertion. Syntax is $ C</p>
<ul>
<li><strong>dw Command:</strong></li>
</ul>
<p>Delete a word using this command. The syntax is $ dw</p>
<ul>
<li><strong>4dw Command:</strong></li>
</ul>
<p>It is used to delete 4 words. The syntax is $ 4dw</p>
<ul>
<li><strong>cw Command:</strong></li>
</ul>
<p>It is used to change a word. Syntax is $ cw</p>
<ul>
<li><strong>x Command:</strong></li>
</ul>
<p>It deletes the character at the cursor. Syntax is $ x</p>
<ul>
<li><strong>r Command:</strong></li>
</ul>
<p>Replace the character. The syntax is $ r</p>
<ul>
<li><strong>R Command:</strong></li>
</ul>
<p>It overwrites characters from cursor onward. The syntax is $ R</p>
<ul>
<li><strong>s Command:</strong></li>
</ul>
<p>Substitute one character under the cursor and continue to insert. The syntax is $ s</p>
<ul>
<li><strong>S Command:</strong></li>
</ul>
<p>Substitutes the entire line and starts to insert at the beginning of the line. The syntax is $ S</p>
<ul>
<li><strong>~ Command:</strong></li>
</ul>
<p>It is used to change the case of the individual character. Syntax is $ ~</p>
<h3><a id="Other_Linux_Commands"></a>Other Linux Commands</h3>
<ul>
<li><strong>adduser/addgroup Command:</strong></li>
</ul>
<p>adduser adds a user and addgroup adds groups to the system. The syntax is $ adduser username</p>
<p><i>Example:</i> $ sudo adduser tech</p>
<ul>
<li><strong>agetty Command:</strong></li>
</ul>
<p>agetty is a program that manages physical or virtual terminals and is invoked by init. It is the substitute for Linux getty.</p>
<p><i>Example:</i> $ agetty -L 9600 ttyS1 vt100</p>
<ul>
<li><strong>alias Command:</strong></li>
</ul>
<p>It is a useful shell built-in command for creating shortcuts to a Linux command on a system.</p>
<p><i>Example:</i> $ alias home&#8217;cd /home/drive/file1&#8242;</p>
<ul>
<li><strong>apropos Command:</strong></li>
</ul>
<p>This is used to search and display a short man page description of a program/ command. The syntax is $ apropos commandname</p>
<p><i>Example:</i> $ apropos rm</p>
<ul>
<li><strong>aptitude Command:</strong></li>
</ul>
<p>It is a powerful text-based interface to the Debian Linux/GNU package management system. The syntax is $ aptitude package</p>
<p><i>Example:</i> $ sudo aptitude update</p>
<ul>
<li><strong>arch Command:</strong></li>
</ul>
<p>This command is used to display the machine architecture or hardware name. The syntax is $ arch</p>
<ul>
<li><strong>arp Command:</strong></li>
</ul>
<p>ARP stands for Address Resolution Protocol that maps IP network addresses of a network neighbor with the hardware (MAC) addresses in an IPv4 network.</p>
<p><i>Example:</i> $ sudo arp-scan &#8211;interface=enp2s0 &#8211;localnet</p>
<ul>
<li><strong>at Command:</strong></li>
</ul>
<p>It is used to schedule tasks to run in the forthcoming time. Syntax is $ at</p>
<p><i>Example:</i> $ sudo echo &#8220;shutdown -h now&#8221; | at -m 15:20</p>
<ul>
<li><strong>atq Command:</strong></li>
</ul>
<p>This command is used to view jobs in at command queue. Syntax is $ atq</p>
<ul>
<li><strong>atrm Command:</strong></li>
</ul>
<p>It is helpful to delete/remove jobs from the queue. $ atrm 2</p>
<ul>
<li><strong>awk Command:</strong></li>
</ul>
<p>Awk is a programming language created for text processing and used as a data extraction and reporting tool.</p>
<p><i>Example:</i> $ awk &#8216;//{print}&#8217;/etc/hosts</p>
<ul>
<li><strong>batch Command:</strong></li>
</ul>
<p>It is similar to at command which is useful to schedule tasks to run in a future time. Syntax is $ batch</p>
<ul>
<li><strong>basename Command:</strong></li>
</ul>
<p>It helps to print the name of a file stripping of directories in absolute path. Syntax is $ basename filename</p>
<p><i>Example:</i> $ basename samplefile</p>
<ul>
<li><strong>bzip2 Command:</strong></li>
</ul>
<p>It is useful to compress or decompress the files. Syntax is $ bzip2 filename</p>
<p><i>Example:</i> $ bzip2 -z filename #Compress</p>
<p>$ bzip2 -d filename.bz2 #Decompress</p>
<ul>
<li><strong>cal Command:</strong></li>
</ul>
<p>This command is used to print a calendar on the standard output. Syntax is $ cal</p>
<ul>
<li><strong>chgrp Command:</strong></li>
</ul>
<p>It is used to change the group ownership of a file. Syntax is $ chgrp new_group_name filename</p>
<p><i>Example:</i> $ chgrp Product Multiplication.txt</p>
<ul>
<li><strong>chmod Command:</strong></li>
</ul>
<p>It is used to change/ update file access permissions. Syntax is $ chmod permission filename</p>
<p><i>Example:</i> $ chmod +x product.txt</p>
<ul>
<li><strong>cksum Command:</strong></li>
</ul>
<p>This command is used to provide the checksum and byte count of the given input file. Syntax is $ cksum filename</p>
<p><i>Example:</i> $ cksum product.txt</p>
<ul>
<li><strong>cmp Command:</strong></li>
</ul>
<p>It compares byte by byte comparison of two files. Syntax is $ cmp file1 file2</p>
<p><i>Example:</i> $ cmp sum add</p>
<ul>
<li><strong>comm Command:</strong></li>
</ul>
<p>It is used to compare two sorted files line by line. Syntax is $ comm file1 file2</p>
<p><i>Example:</i> $ comm product multiplication</p>
<ul>
<li><strong>cp Command:</strong></li>
</ul>
<p>It copies files and directories from one location to another. Syntax is $ cp location1 location2</p>
<p><i>Example:</i> $ cp /home/arithmetic/add /home/arithmetic/product/</p>
<ul>
<li><strong>date Command:</strong></li>
</ul>
<p>It displays/ sets the system date and time. Syntax is $ date</p>
<p><i>Example:</i> $ date &#8211;set=&#8221;20 Oct 2020 10:35:05&#8243;</p>
<ul>
<li><strong>diff Command:</strong></li>
</ul>
<p>The double advantage of this command is used to compare two files line by line and used to find the difference between two directories. Syntax is $ diff file1 file2</p>
<p><i>Example:</i> $ diff sum add</p>
<ul>
<li><strong>dmidecode Command:</strong></li>
</ul>
<p>It retrieves the hardware information of any linux system. Syntax is $ dmidecode</p>
<p><i>Example:</i> $ sudo dmidecode &#8211;type system</p>
<ul>
<li><strong>du Command:</strong></li>
</ul>
<p>It shows the disk space usage of files present in the directory as well as its subdirectories. The syntax is $ du directory</p>
<p><i>Example:</i> $ du /home/arithmetic</p>
<ul>
<li><strong>eject Command:</strong></li>
</ul>
<p>eject command is used to eject removable media such as CD/DVD/ROM/floppy disk from the system. The syntax is $ eject disklocation</p>
<p><i>Example:</i> $ eject /dev/cdrom</p>
<ul>
<li><strong>exit Command:</strong></li>
</ul>
<p>It is used to exit a shell. The syntax is $ exit</p>
<ul>
<li><strong>expr Command:</strong></li>
</ul>
<p>It is used to calculate an expression. The syntax is $ expr expression</p>
<p><i>Example:</i> $ expr 15 * 5</p>
<ul>
<li><strong>factor Command:</strong></li>
</ul>
<p>It is used to display the prime factors of a number. The syntax is $ factor number</p>
<p><i>Example:</i> $ factor 18</p>
<ul>
<li><strong>find Command:</strong></li>
</ul>
<p>It searches for files in the directory and its subdirectories. The syntax is $ find directory filename</p>
<p><i>Example</i>: $ find /home/add/ -name product.txt</p>
<ul>
<li><strong>grep Command:</strong></li>
</ul>
<p>It searches for a specified pattern in the file and displays the output as lines containing that pattern. The syntax is $ grep</p>
<p><i>Example:</i> $ grep ‘linuxcent’ domain-list.txt</p>
<ul>
<li><strong>groups Command:</strong></li>
</ul>
<p>Shows all names of groups of a user. The syntax is $ groups</p>
<ul>
<li><strong>gzip Command:</strong></li>
</ul>
<p>It helps to compress a file and replaces it with one having a .gz extension. The syntax is gzip filename</p>
<p>Example: $ gzip passwds.txt</p>
<ul>
<li><strong>gunzip Command:</strong></li>
</ul>
<p>It expands or restores files compressed with the gzip command. The syntax is $ gunzip gzfilename</p>
<p><i>Example:</i> $ gunzip sum.gz</p>
<ul>
<li><strong>head Command:</strong></li>
</ul>
<p>It is helpful to display the first 10 lines of the specified file or stdin to the screen. The syntax is $ head</p>
<ul>
<li><strong>hostname Command:</strong></li>
</ul>
<p>This command is useful to print or set the system hostname. The syntax is $ hostname</p>
<p><i>Example:</i> $ hostname New_hostname</p>
<ul>
<li><strong>id Command:</strong></li>
</ul>
<p>It shows user &amp; group information for the current user or specified user. The syntax is $ id username</p>
<p><i>Example:</i> $ id linuxcent</p>
<ul>
<li><strong>ifconfig Command:</strong></li>
</ul>
<p>It is used to configure Linux system network interfaces. The syntax is $ ifconfig</p>
<ul>
<li><strong>ionice Command:</strong></li>
</ul>
<p>This command is used to set or view process I/O scheduling class and priority of the specified process. The syntax is $ ionice process</p>
<p><i>Example:</i> $ ionice -c 3 rm /var/logs/syslog</p>
<ul>
<li><strong>iostat Command:</strong></li>
</ul>
<p>iostat command is helpful to show the CPU and i/o statistics for devices and partitions. The syntax is $ iostat</p>
<ul>
<li><strong>ip Command:</strong></li>
</ul>
<p>It is used to display or manage devices, routing, policy routing, and tunnels. The syntax is $ ip addr</p>
<ul>
<li><strong>iw Command:</strong></li>
</ul>
<p>This is used to manage wireless devices and their configuration. The syntax is $ iw</p>
<p><i>Example:</i> $ iw list</p>
<ul>
<li><strong>killall Command:</strong></li>
</ul>
<p>It kills a process with the help of its name. The syntax is $ killall processname</p>
<p><i>Example:</i> $ killall process1</p>
<ul>
<li><strong>kmod Command:</strong></li>
</ul>
<p>It is useful to manage Linux kernel modules. To list all currently loaded modules, type. Syntax is $ kmod</p>
<p><i>Example:</i> $ kmod list</p>
<ul>
<li><strong>last Command:</strong></li>
</ul>
<p>It displays a list of last logged in users. The syntax is $ last</p>
<ul>
<li><strong>ln Command:</strong></li>
</ul>
<p>This is used to create a soft link between files using -s flag. Syntax is $ ln -s file1 file2</p>
<p><i>Example:</i> $ ln -s product multiplication</p>
<ul>
<li><strong>locate Command:</strong></li>
</ul>
<p>It is used to find a file with its name. The syntax is $ locate filename</p>
<p><i>Example:</i> $ locate -b &#8216;add.txt&#8217;</p>
<ul>
<li><strong>lshw Command:</strong></li>
</ul>
<p>It gives detailed information on the hardware configuration of the machine. The syntax is $ lshw</p>
<ul>
<li><strong>lscpu Command:</strong></li>
</ul>
<p>This Linux command displays the system&#8217;s CPU architecture information. The syntax is $ lscpu</p>
<ul>
<li><strong>lsof Command:</strong></li>
</ul>
<p>It displays information related to files opened by processes. The syntax is $ lsof processname</p>
<p><i>Example:</i> $ lsof -u add</p>
<ul>
<li><strong>lsusb Command:</strong></li>
</ul>
<p>It shows information: about USB buses in the system and devices connected to them. The syntax is $ lsusb</p>
<ul>
<li><strong>md5sum Command:</strong></li>
</ul>
<p>This command is used to compute and print the MD5 message digest of the file.</p>
<ul>
<li><strong>more Command:</strong></li>
</ul>
<p>It enables to view through relatively lengthy text files one screenful at a time. The syntax is $ more filename</p>
<p><i>Example:</i> $ more add</p>
<ul>
<li><strong>nano Command:</strong></li>
</ul>
<p>You can open a file using this nano command. The syntax is $ nano filename</p>
<p><i>Example:</i> $ nano sum</p>
<ul>
<li><strong>netstat Command:</strong></li>
</ul>
<p>It displays useful information such as routing tables, network connections, and others about Linux networking subsystems. Syntax is $ netstat</p>
<p><i>Example:</i> $ netstat -a | more</p>
<ul>
<li><strong>nproc Command:</strong></li>
</ul>
<p>It shows the number of processing units present to the current process. The syntax is $ nproc</p>
<ul>
<li><strong>passwd Command:</strong></li>
</ul>
<p>This command is used to create/update passwords for user accounts. The syntax is $ passwd username</p>
<p><i>Example:</i> $ passwd user1</p>
<ul>
<li><strong>pstree Command:</strong></li>
</ul>
<p>It displays running processes as a tree that is rooted at either PID or init if PID is omitted. The syntax is $ pstree</p>
<ul>
<li><strong>reboot Command:</strong></li>
</ul>
<p>This command is used to power-off, halt, or reboot a system. The syntax is $ reboot</p>
<ul>
<li><strong>scp Command:</strong></li>
</ul>
<p>It enables you to securely copy files between hosts on a network. Syntax is $ scp</p>
<p><i>Example:</i> $ scp ~/names.txt root@192.168.56.10:/root/names.txt</p>
<ul>
<li><strong>shutdown Command:</strong></li>
</ul>
<p>It schedules a time for the system to be powered down. Its syntax is $ shutdown</p>
<p><i>Example:</i> $ shutdown &#8211;poweroff</p>
<ul>
<li><strong>sleep Command:</strong></li>
</ul>
<p>This command is used to pause or delay for a specific amount of time. The syntax is $ sleep</p>
<p><i>Example:</i> $ check.sh; sleep 5; sudo apt update</p>
<ul>
<li><strong>sort Command:</strong></li>
</ul>
<p>This is used to sort lines of text in the specified files from stdin. The syntax is $ sort</p>
<p><i>Example:</i> $ sort add.txt</p>
<ul>
<li><strong>split Command:</strong></li>
</ul>
<p>It is used to split a large file into smaller pieces. The syntax is $ split filename</p>
<p><i>Example:</i> $ split add</p>
<ul>
<li><strong>stat Command:</strong></li>
</ul>
<p>It is helpful to know the file system status. The syntax is $ state filename</p>
<p><i>Example:</i> $ stat -f add.txt</p>
<ul>
<li><strong>su Command:</strong></li>
</ul>
<p>It is used to switch to another user ID or become root during a login session. The syntax is $ su</p>
<ul>
<li><strong>sum Command:</strong></li>
</ul>
<p>This command shows the checksum and blocks counts for all files on the command line. The syntax is $ sum output filename</p>
<p><i>Example:</i> $ sum output add.txt</p>
<ul>
<li><strong>tac Command:</strong></li>
</ul>
<p>It concentrates and displays files in reverse. It prints each file to the standard output, shows the last line first. The syntax is $ tac filename</p>
<p><i>Example:</i> $ tac sum.txt</p>
<ul>
<li><strong>tail Command:</strong></li>
</ul>
<p>It displays the last 10 lines of each file. The syntax is $ tail filename</p>
<p><i>Example:</i> $ tail sum.txt</p>
<ul>
<li><strong>talk Command:</strong></li>
</ul>
<p>talk is used to talk to another network user/ system. Use a login name to talk to the user on the same machine and use &#8216;use@host&#8217; to talk to a user on another machine. The syntax is $ talk</p>
<p><i>Example:</i> $ talk person [ttyname] or $ talk ‘user@host’ [ttyname]</p>
<ul>
<li><strong>tee Command:</strong></li>
</ul>
<p>This is used to read from standard input &amp; prints to standard output and files.</p>
<p>Example: $ echo &#8220;Testing how tee command works&#8221; | tee file1</p>
<ul>
<li><strong>time Command:</strong></li>
</ul>
<p>This command runs programs and summarizes system resource usage. The syntax is $ time</p>
<ul>
<li><strong>touch Command:</strong></li>
</ul>
<p>It changes file timestamps and it is used to create a file. The syntax is $ touch filename</p>
<ul>
<li><strong>uname Command:</strong></li>
</ul>
<p>It displays system information such as operating system, network node hostname kernel name, version, and release, etc. Syntax is $ uname</p>
<ul>
<li><strong>uniq Command:</strong></li>
</ul>
<p>It displays or omits repeated lines from input. The syntax is $ uniq</p>
<ul>
<li><strong>uptime Command:</strong></li>
</ul>
<p>It shows how long the system has been running, the number of logged on users, and system load averages. The syntax is $ uptime</p>
<ul>
<li><strong>wall Command:</strong></li>
</ul>
<p>This command is used to send/display a message to all users on the system. The syntax is $ wall &#8220;message&#8221;</p>
<p><i>Example:</i> $ wall &#8220;This is Linux operating system&#8221;</p>
<ul>
<li><strong>wc Command:</strong></li>
</ul>
<p>This command displays the word, newline, and byte counts for each file. The syntax is $ wc filename</p>
<p><i>Example:</i> $ wc add.txt</p>
<ul>
<li><strong>whatis Command:</strong></li>
</ul>
<p>It searches &amp; shows a short or one-line manual page description of the provided command name. The syntax is $ whatis wget</p>
<ul>
<li><strong>who Command:</strong></li>
</ul>
<p>It shows details about users who are currently logged in. The syntax is $ who</p>
<ul>
<li><strong>which Command:</strong></li>
</ul>
<p>This command is used to get the absolute path of the file which would be executed in the current environment. The syntax is $ which who</p>
<ul>
<li><strong>whereis Command:</strong></li>
</ul>
<p>It helps to locate binary, source and manual files for commands. The syntax is $ whereis cat</p>
<ul>
<li><strong>yes Command:</strong></li>
</ul>
<p>This command is used to display a string repeatedly until when terminated or killed. The syntax is 4 yes</p>
<p><i>Example:</i> $ yes &#8220;This is LinuxCent &#8211; Linux HowTos&#8221;</p>
<ul>
<li><strong>zcmp/zdiff Command:</strong></li>
</ul>
<p>zcmp and zdiff minimal utilities used to compare compressed files. Syntax is $ zcmp filesnames, $ zdiff filesnames</p>
<p><i>Example:</i> $ zcmp domain-list.txt.zip basic_passwords.txt.zip</p>
<p>$ zdiff domain-list.txt.zip basic_passwords.txt.zip</p>
<ul>
<li><strong>zip Command:</strong></li>
</ul>
<p>It is simple &amp; easy to use utility used to package &amp; compress files. Syntax is $ zip packagename</p>
<p><i>Example:</i> $ zip inarchive.zip foo.c bar.c &#8211;out outarchive.zip</p>
<p>We have mentioned all the Linux commands in the Linux Commands Cheatsheet. Make use of these countless commands that you might feel helpful.</p>
<h2>What are 5 Linux commands?</h2>
<p><strong>Linux File commands</strong></p>
<ul>
<li>touch Command. The touch command is used to create empty files. &#8230;</li>
<li>cat Command. The cat command is a multi-purpose utility in the Linux system. &#8230;</li>
<li>rm Command. The rm command is used to remove a file.</li>
<li>cp Command. The cp command is used to copy a file or directory.</li>
<li>mv Command. &#8230;</li>
<li>rename Command.</li>
</ul>
<h2>How do I see all commands in Linux?</h2>
<p>In Linux, there is a very useful command to show you all of the last commands that have been recently used. The command is simply called history, but can also be accessed by looking at your . bash_history in your home folder. By default, the history command will show you the last five hundred commands you have entered.</p>
<p>What is Linux cheat sheet?<br />
Basic Linux commands</p>
<p><img decoding="async" class="alignnone wp-image-1296 size-full" src="https://linuxcent.com/wp-content/uploads/2021/08/What-is-Linux-cheat-sheet.png" alt="What is Linux cheat sheet? " width="680" height="234" srcset="https://linuxcent.com/wp-content/uploads/2021/08/What-is-Linux-cheat-sheet.png 680w, https://linuxcent.com/wp-content/uploads/2021/08/What-is-Linux-cheat-sheet-300x103.png 300w" sizes="(max-width: 680px) 100vw, 680px" /></p>
<h2>How many commands are in Linux?</h2>
<p>There are well over 100 Unix commands shared by the Linux kernel and other Unix-like operating systems.</p>
<h2>What does F do in Linux?</h2>
<p>Many Linux commands have an -f option, which stands for, you guessed it, force! Sometimes when you execute a command, it fails or prompts you for additional input. This may be an effort to protect the files you are trying to change or inform the user that a device is busy or a file already exists.</p>
<h2>How do I get a list of commands?</h2>
<p>You can open the Command Prompt by pressing ⊞ Win + R to open the Run box and typing cmd. Windows 8 users can also press ⊞ Win + X and select Command Prompt from the menu. Retrieve the list of commands.</p>
<h2>How do you list all commands in Terminal?</h2>
<p>Just tap the Tab key twice ( Tab Tab ). You&#8217;ll be prompted if you want to see all possible commands. Tap y and you&#8217;ll be presented with a list. You can do that same thing for individual commands to see all options for that specific command.</p>
<h2>How do you write commands in Linux?</h2>
<p>Linux operating system allows users to create commands and execute them over the command line. To create a command in Linux, the first step is to create a bash script for the command. The second step is to make the command executable. Here, bashrc means run the Bash file.</p>
<h2>What does Linux dd command do?</h2>
<p>dd is a command-line utility for Unix and Unix-like operating systems, the primary purpose of which is to convert and copy files. &#8230; As a result, dd can be used for tasks such as backing up the boot sector of a hard drive, and obtaining a fixed amount of random data.</p>
<h2>What is Yum in Linux?</h2>
<p>YUM is the primary package management tool for installing, updating, removing, and managing software packages in Red Hat Enterprise Linux. YUM performs dependency resolution when installing, updating, and removing software packages. YUM can manage packages from installed repositories in the system or from</p>
<h2>What is Sudo in Linux?</h2>
<p>Sudo stands for either &#8220;substitute user do&#8221; or &#8220;super user do&#8221; and it allows you to elevate your current user account to have root privileges temporarily. This is different from “su” which is not temporary.</p>
<h2>How use Linux command line?</h2>
<p>On many systems, you can open a command window by pressing the Ctrl+Alt+t keys at the same time. You will also find yourself on the command line if you log into a Linux system using a tool like PuTTY. Once you get your command line window, you&#8217;ll find yourself sitting at a prompt.</p>
<h2>What is Ubuntu command?</h2>
<p>The latest LTS release is 20.04; it will be available till 2025. Ubuntu supports both Command Line Interface (CLI) and Graphical User Interface (GUI) to perform various tasks on the OS. CLI is the basic way to interact with systems hardware (processor/memory); you can perform all the tasks that GUI can perform.</p>
<h2>Where is Linux command?</h2>
<p>The whereis command in Linux is used to locate the binary, source, and manual page files for a command. This command searches for files in a restricted set of locations (binary file directories, man page directories, and library directories).</p>
<p><a class="a2a_button_mastodon" href="https://www.addtoany.com/add_to/mastodon?linkurl=https%3A%2F%2Flinuxcent.com%2Flinux-commands-cheat-sheet%2F&amp;linkname=Linux%20Commands%20Cheat%20Sheet" title="Mastodon" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_email" href="https://www.addtoany.com/add_to/email?linkurl=https%3A%2F%2Flinuxcent.com%2Flinux-commands-cheat-sheet%2F&amp;linkname=Linux%20Commands%20Cheat%20Sheet" title="Email" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_whatsapp" href="https://www.addtoany.com/add_to/whatsapp?linkurl=https%3A%2F%2Flinuxcent.com%2Flinux-commands-cheat-sheet%2F&amp;linkname=Linux%20Commands%20Cheat%20Sheet" title="WhatsApp" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Flinuxcent.com%2Flinux-commands-cheat-sheet%2F&amp;linkname=Linux%20Commands%20Cheat%20Sheet" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_x" href="https://www.addtoany.com/add_to/x?linkurl=https%3A%2F%2Flinuxcent.com%2Flinux-commands-cheat-sheet%2F&amp;linkname=Linux%20Commands%20Cheat%20Sheet" title="X" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Flinuxcent.com%2Flinux-commands-cheat-sheet%2F&amp;linkname=Linux%20Commands%20Cheat%20Sheet" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_copy_link" href="https://www.addtoany.com/add_to/copy_link?linkurl=https%3A%2F%2Flinuxcent.com%2Flinux-commands-cheat-sheet%2F&amp;linkname=Linux%20Commands%20Cheat%20Sheet" title="Copy Link" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Flinuxcent.com%2Flinux-commands-cheat-sheet%2F&#038;title=Linux%20Commands%20Cheat%20Sheet" data-a2a-url="https://linuxcent.com/linux-commands-cheat-sheet/" data-a2a-title="Linux Commands Cheat Sheet"></a></p><p>The post <a href="https://linuxcent.com/linux-commands-cheat-sheet/">Linux Commands Cheat Sheet</a> appeared first on <a href="https://linuxcent.com">Linuxcent</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://linuxcent.com/linux-commands-cheat-sheet/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">975</post-id>	</item>
		<item>
		<title>create multiple files and Directories at once in Windows Command line</title>
		<link>https://linuxcent.com/create-multiple-files-and-directories-at-once-in-windows-command-line/</link>
					<comments>https://linuxcent.com/create-multiple-files-and-directories-at-once-in-windows-command-line/#respond</comments>
		
		<dc:creator><![CDATA[Vamshi Krishna Santhapuri]]></dc:creator>
		<pubDate>Sat, 25 Apr 2020 08:46:39 +0000</pubDate>
				<category><![CDATA[Commands]]></category>
		<guid isPermaLink="false">https://linuxcent.com/?p=384</guid>

					<description><![CDATA[<p><span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> &#60; 1</span> <span class="rt-label rt-postfix">minute</span></span>The windows commandline also known as cmd provides the cli interaction to the windows operating system. The Windows powershell which has been recently made opensource provides cross platform compatibility and can also be installed on Linux OS. The command to create a file in Powershell: PS /home/vamshi&#62; New-Item -ItemType file testfile.txt There is another simpler ... <a title="create multiple files and Directories at once in Windows Command line" class="read-more" href="https://linuxcent.com/create-multiple-files-and-directories-at-once-in-windows-command-line/" aria-label="Read more about create multiple files and Directories at once in Windows Command line">Read more</a></p>
<p>The post <a href="https://linuxcent.com/create-multiple-files-and-directories-at-once-in-windows-command-line/">create multiple files and Directories at once in Windows Command line</a> appeared first on <a href="https://linuxcent.com">Linuxcent</a>.</p>
]]></description>
										<content:encoded><![CDATA[<span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> &lt; 1</span> <span class="rt-label rt-postfix">minute</span></span><p>The windows commandline also known as cmd provides the cli interaction to the windows operating system.</p>
<p>The Windows powershell which has been recently made opensource provides cross platform compatibility and can also be installed on Linux OS.</p>
<p>The command to create a file in Powershell:</p>
<pre>PS /home/vamshi&gt; New-Item -ItemType file testfile.txt</pre>
<p>There is another simpler way to create a file in windows and also used often in Linux/Unix</p>
<pre>PS /home/vamshi&gt; echo " " &gt; testfile2.txt</pre>
<pre>PS /home/cloud_user&gt; dir

Directory: /home/vamshi

Mode LastWriteTime Length Name
---- ------------- ------ ----
----- 04/25/2020 07:40 2 testfile.txt
----- 04/25/2020 07:40 2 testfile2.txt
</pre>
<p>Command to create a Directory in Powershell.</p>
<pre>PS /home/vamshi&gt;New-Item -ItemType directory testDir.</pre>
<p>How to create multiple files in Windows using Command-line?</p>
<p>Write down the list of all filenames in a file filenames.txt as below:</p>
<pre>PS /home/vamshi&gt; cat filenames.txt
file1
file2
file3
file4</pre>
<p>To achieve this we have to create a for loop.</p>
<pre>PS /home/vamshi&gt; cat filenames.txt | foreach-object -process { echo "" &gt; $_ }</pre>
<pre>PS /home/cloud_user&gt; dir

Directory: /home/vamshi

Mode LastWriteTime Length Name
---- ------------- ------ ----
----- 04/25/2020 07:49 1 file1
----- 04/25/2020 07:49 1 file2
----- 04/25/2020 07:49 1 file3
----- 04/25/2020 07:49 1 file4</pre>
<p>The foreach command can be used along with <code>New-Item -ItemType</code> as below:</p>
<pre>PS /home/vamshi&gt; cat filenames.txt | foreach-object -process { New-Item -ItemType file $_ }</pre>
<p>Create multiple Directories in windows:</p>
<pre>PS /home/vamshi&gt; cat ./dirs.txt
dir1
dir2
dir3</pre>
<pre>PS /home/vamshi&gt; cat ./newdirs.txt | foreach-object -process { New-Item -ItemType directory $_ }
PS /home/vamshi&gt; dir
Directory: /home/vamshi
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 04/25/2020 07:54 dir1
d---- 04/25/2020 07:54 dir2
d---- 04/25/2020 07:54 dir3</pre>
<p><a class="a2a_button_mastodon" href="https://www.addtoany.com/add_to/mastodon?linkurl=https%3A%2F%2Flinuxcent.com%2Fcreate-multiple-files-and-directories-at-once-in-windows-command-line%2F&amp;linkname=create%20multiple%20files%20and%20Directories%20at%20once%20in%20Windows%20Command%20line" title="Mastodon" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_email" href="https://www.addtoany.com/add_to/email?linkurl=https%3A%2F%2Flinuxcent.com%2Fcreate-multiple-files-and-directories-at-once-in-windows-command-line%2F&amp;linkname=create%20multiple%20files%20and%20Directories%20at%20once%20in%20Windows%20Command%20line" title="Email" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_whatsapp" href="https://www.addtoany.com/add_to/whatsapp?linkurl=https%3A%2F%2Flinuxcent.com%2Fcreate-multiple-files-and-directories-at-once-in-windows-command-line%2F&amp;linkname=create%20multiple%20files%20and%20Directories%20at%20once%20in%20Windows%20Command%20line" title="WhatsApp" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Flinuxcent.com%2Fcreate-multiple-files-and-directories-at-once-in-windows-command-line%2F&amp;linkname=create%20multiple%20files%20and%20Directories%20at%20once%20in%20Windows%20Command%20line" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_x" href="https://www.addtoany.com/add_to/x?linkurl=https%3A%2F%2Flinuxcent.com%2Fcreate-multiple-files-and-directories-at-once-in-windows-command-line%2F&amp;linkname=create%20multiple%20files%20and%20Directories%20at%20once%20in%20Windows%20Command%20line" title="X" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Flinuxcent.com%2Fcreate-multiple-files-and-directories-at-once-in-windows-command-line%2F&amp;linkname=create%20multiple%20files%20and%20Directories%20at%20once%20in%20Windows%20Command%20line" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_copy_link" href="https://www.addtoany.com/add_to/copy_link?linkurl=https%3A%2F%2Flinuxcent.com%2Fcreate-multiple-files-and-directories-at-once-in-windows-command-line%2F&amp;linkname=create%20multiple%20files%20and%20Directories%20at%20once%20in%20Windows%20Command%20line" title="Copy Link" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Flinuxcent.com%2Fcreate-multiple-files-and-directories-at-once-in-windows-command-line%2F&#038;title=create%20multiple%20files%20and%20Directories%20at%20once%20in%20Windows%20Command%20line" data-a2a-url="https://linuxcent.com/create-multiple-files-and-directories-at-once-in-windows-command-line/" data-a2a-title="create multiple files and Directories at once in Windows Command line"></a></p><p>The post <a href="https://linuxcent.com/create-multiple-files-and-directories-at-once-in-windows-command-line/">create multiple files and Directories at once in Windows Command line</a> appeared first on <a href="https://linuxcent.com">Linuxcent</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://linuxcent.com/create-multiple-files-and-directories-at-once-in-windows-command-line/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">384</post-id>	</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 

Served from: linuxcent.com @ 2026-08-22 09:49:24 by W3 Total Cache
-->