• Categories
    Category
  • Categories
    Category
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial Comments FAQ Related Articles

How to use mkdir, tar and kill commands efficiently in Linux

149

To use mkdir, tar and kill commands efficiently in Linux

In this tutorial how to use mkdir, tar and kill commands efficiently in Linux command efficiently is illustrated with examples.

Using mkdir create directory tree

[root@linuxhelp Desktop]# mkdir folder
[root@linuxhelp Desktop]# cd folder
[root@linuxhelp folder]# mkdir image
[root@linuxhelp folder]# cd image/
[root@linuxhelp image]# mkdir video
[root@linuxhelp image]# cd video
[root@linuxhelp Desktop]# tree folder
folder
??? image
    ??? video
2 directories, 0 files

The above method is very long process to create the directory tree.

Create the directory tree efficiently

mkdir with option -p will create the long directory tree in single command.

[root@linuxhelp Desktop]# mkdir -p mydir/dir/a1/b2/c3
[root@linuxhelp Desktop]# tree mydir
mydir
??? dir
    ??? a1
        ??? b2
            ??? c3

4 directories, 0 files

To create and view the files

To create the file use touch command.

[root@linuxhelp Desktop]# touch my.txt

Once the text file is created, add the contents by using editor like vim ,vi ,nano&hellip etc.

[root@linuxhelp Desktop]# vim my.txt
Centos
Redhat
Ubuntu

Now the next step if you want to view your created file by using same editors use the following command.

[root@linuxhelp Desktop]# vim my.txt

So this method also takes some time to create the file and add the contents to that file.

To create the file using cat command

Using cat command it will simple to create the file and also easy view the created file.

[root@linuxhelp Desktop]# cat < <  EOF >  file.txt
linux
window

To view the content of created files

[root@linuxhelp Desktop]# cat file.txt
linux
window

We often deal with archives on Linux and in several cases we use TAR ball on some location other than the downloads folder.
In such a situation we normally do the following method

First we start copy or move the tar ball and extract it at the destination.

[root@linuxhelp Desktop]# cp folder.tar /root/Documents/
[root@linuxhelp Desktop]# cd  ../Documents
[root@linuxhelp Documents]# ls
folder.tar
[root@linuxhelp Documents]# tar -xvf folder.tar
folder/
folder/image/
folder/image/video/

So these method will take little longer steps. The below command will overcome this issue.

[root@linuxhelp Desktop]# tar -xvf mydir.tar.gz -C /root/Downloads
mydir/
mydir/music/
mydir/music/s2/
mydir/music/s1/
mydir/dir/
.
.
.
mydir/{number/
mydir/{number/a1/
mydir/{number/a1/b1}/

Option C is used to mention the destination path

[root@linuxhelp Desktop]# cd ../Downloads/
[root@linuxhelp Downloads]# ls
mydir

To kill the process and view the status

Usually we first list all the process using ps -A and pipeline it with grep to find a process or a service:

[root@linuxhelp Desktop]# ps -A | grep -i python
 3059 ?        00:00:01 python

Now let us kill the above process id.

[root@linuxhelp Desktop]#kill 3059
[root@linuxhelp Desktop]# ps -A | grep -i python

To view the process details and delete the process

To view the process details and delete the process by using pgrep and pkill commands.
You may find relevant information about a process just by using pgrep. To kill a process, just type pkill followed by the process to kill.

[root@linuxhelp Desktop]# ps -A | grep -i gnote
 3032 ?        00:00:01 gnote
[root@linuxhelp Desktop]# pgrep gnote
3032
[root@linuxhelp Desktop]# pgrep -l gnote
3032 gnote
[root@linuxhelp Desktop]# pkill gnote
[root@linuxhelp Desktop]# pgrep -l gnote

Tags:
matthew
Author: 

Comments ( 0 )

No comments available

Add a comment

Frequently asked questions ( 5 )

Q

How can I grep and find one particular service say, Perl?

A

Use the below command "ps -A | grep -i Perl" for achieving it

Q

What are those options -x and -v used in tar command?

A

"-x" for extracting and "-v" for verbose is used in tar command.

Q

Where to find the port is up and listening or not?

A

ps can also be used but for better efficiency use "netstat" and "lsof" too.

Q

Option for killing a process?

A

Use kill -9 PID or kill -15 PID.

Q

What if I wanted to delete a process?

A

To view the process details and delete the process by using "pgrep" and "pkill" commands, identify the process and kill it.

Related Tutorials in How to use mkdir, tar and kill commands efficiently in Linux

Related Tutorials in How to use mkdir, tar and kill commands efficiently in Linux

FFmpeg Commands in Linux with Examples
FFmpeg Commands in Linux with Examples
Apr 4, 2016
Basic Linux Command Line Tricks
Basic Linux Command Line Tricks
Apr 20, 2016
Useful commands to manage Desktop and Server in Linux - Part 1
Useful commands to manage Desktop and Server in Linux - Part 1
Apr 27, 2016
Useful commands to manage Desktop and Server in Linux - Part 2
Useful commands to manage Desktop and Server in Linux - Part 2
Apr 27, 2016
How to use mkdir, tar and kill commands efficiently in Linux
How to use mkdir, tar and kill commands efficiently in Linux
Apr 19, 2016
Interesting Command Line Tips and Tricks in Linux
Interesting Command Line Tips and Tricks in Linux
Apr 5, 2016
How to run Linux commands every X seconds
How to run Linux commands every X seconds
Mar 25, 2016

Related Forums in How to use mkdir, tar and kill commands efficiently in Linux

Related Forums in How to use mkdir, tar and kill commands efficiently in Linux

CentOS
isaiah class=
pidstat no found
May 28, 2018
Basic Commands
FerTah class=
Command sort or uniq
Apr 10, 2019
Windows
Aditya class=
Net view usage in Windows 10
Jul 31, 2019
Basic Commands
gibbson class=
How to install locate command
Aug 25, 2018
Basic Commands
yousuf class=
How to check history command with time
Aug 25, 2018
Basic Commands
raven class=
Basic Commans are not working
Dec 29, 2017
CentOS
muhammad class=
list files on created time
Jun 12, 2018
Basic Commands
elijah class=
How to List only Directories from the Current Location in Linux
Dec 18, 2019
Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Ryan ?
how to use visual traceroute tool

Am using traceroute command to check for the route. i got this tool while surfing. So pls help me out installation and usage of Visual traceroute tool.

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.