Postingan

Menampilkan postingan dengan label unix

Linux Command to Find how Long a process is Running in UNIX

Gambar
Hello guys, today, I am going to share one of the useful tips to find out how long a particular process is running in Linux. This is very useful while you are troubleshooting an issue and want to know whether your process or service is restarted fine on a daily or weekly basis. So you checked your process is running in Linux operating system and it's running fine, by using ps command. But now you want to know, from how long process is running , what is the start date of that process etc. Unfortunately, PS command in Linux or any UNIX based operating system doesn't provide that information. But as said, UNIX or Linux has commands for almost everything and if there is no command, you can also check some important files in the /etc directory to find out some useful info. It’s been a long time, I have posted any UNIX or Linux command tutorial, after sharing some UNIX productivity tips. Hence, I am going to share this nice little tip, which you can use to check how long a particular...

How to find and kill a Process Listening on a port in Linux? netstat and lsof command examples

Gambar
In Linux, many times, you want to find out the PID of a process which is listening on a port e.g. if multiple tomcat servers are running on a host and you have to kill that process, but in order to kill that process you need the process id, how do you find the PID of the tomcat listening on port 8080? There are many Linux commands to find the process using a specific port, but I'll share what I use. I always use the netstat command with -p option , which displays process id of the process listening on a port. Btw, netstat is not the only command to find all processes using a particular port , you can also use the lsof command for the same purpose. If you remember, we have used lsof earlier to find all the processes accessing a file but it can also be used to find all processes accessing a specific port. You will see the example of both netstat and lsof commands in this article to find the PID of process listening on a specific port in Linux. On the related note, it's very impo...

10 Example of find command in UNIX and Linux

Gambar
The find command is one of the most versatile commands in UNIX and Linux, and I used it a lot in my day to day work. I believe having a good knowledge of find command in UNIX and understanding of its different options and usage will increase your productivity a lot in UNIX based operating system, e.g. Redhat Linux or Solaris. If you are a QA, support personnel, and your works involve lots of searching text on Linux machine or if you are a Java or C++ programmer and your code resides in UNIX, find command can significantly help you to look for any word inside your source file in the absence of an IDE. It is the alternative way of searching for things in UNIX; grep is another Linux command which provides similar functionality like find but in my opinion, later is much more potent than grep in UNIX. Like any other command strength to find lies in its various options , which is worth learning, but, to be frank, hard to remember. If you can be even able to remember all the options men...

10 Tips Improve Your Speed in Bash, and Linux Command Line

Gambar
Have you ever amazed to see someone working very fast in UNIX, firing commands, and doing things quickly? Yes, I have noticed that a couple of times, and I have always inspired to learn from those superstar developers. In this article or tutorial or whatever you call it, I have dedicated to sharing some UNIX command practices I follow to work fast, quick, or efficiently in Linux. I work for the Financial services industry, and my work involves the development and support of online stock and futures trading applications in Electronic trading, Derivatives, etc. All our services run on Linux servers, so I need to work efficiently and quickly in the Linux machine, and that's how I have learned these productivity tips in Linux. This article is in continuation of my earlier article Top 10 basic networking Commands in Unix and How does nslookup command work in Linux. If you have not read those, you can see if you find them interesting and useful. In this UNIX command tutorial, I am going ...

10 Example of lsof commands in Linux and UNIX

Gambar
It's been a long time since I have written anything on UNIX or Linux commands. Still, today, I'll talk about the lsof command , a utility command every system admin and developers love. The lsof command stands for list open file descriptors, and as the name suggests, it is used to find open files by the process. Since almost everything in UNIX are file, you can use lsof command to find an open regular file, a directory, a symbolic link, a special block file, an NFS mounted file, a socket stream, a shared library, a special character file, a regular pipe, a named pipe, an internet socket, a UNIX domain socket, and many others. I have mostly used it to find all the files opened by a particular process, which I will show you in the next section. It's an incredibly useful tool to do debugging and troubleshooting in UNIX and Linux environments. Because of its versatile nature, it's also known as the " The Swiss Army Knife of Linux." Since most of the production s...

Top 10 UNIX and Linux System Programming Books- Best of Lot, Must Read

Gambar
I have been sharing programming books in this blog for a long time, starting with core Java; I moved to other related technology, likeSpring, Design patterns, Data Structure and Algorithms, etc. Today, I am going to share some of the best UNIX and Linux programming books . The list contains some of the must-read UNIX books from great writers like Sir Richard. Stevens, Sir Brain Kernighan, who has contributed so much to the development of the UNIX operating system. Most of the books on this list are timeless,  classic, and don't age with time, much like UNIX, which is around for the last 40 years, and I am sure it will be around for the next 40 years, or maybe forever. If you don't know, I love books, both reading and collecting. I have a strong passion for finding high-quality publications and already having 100s of titles in my bookshelf. I am reading books from my childhood when I started reading pocketbooks, comics, magazines, storybooks, and then slowly moved on to Physics,...

How to send HTTP request using curl and wget command from Linux and UNIX? Example Tutorial

Gambar
You can use either curl or wget command to send HTTP requests from UNIX or Linux operating system. Both commands allow you to send GET and POST requests, which means you can also call REST web services.  I have a Java web application, which runs on Linux and exposes WebServices. I was writing a UNIX script to download In some data from that web service when I hit by the question, how do I make an HTTP call from UNIX? What is the UNIX command should I use? If you are also facing the same problem, then you have come to the right ht place. Basically, you can use two UNIX commands to make the HTTP request, wget, and curl. You can use curl and wget to send both GET and POST HTTP requests. My use case was rather simple, I just need to make a GET call to web service to download the data, but these two commands are mighty and provide many different options to interact with the web using HTTP right from the shell. Between wget and curl (also known as cURL), curl (I call it "karl") ...

How to find IP Address from hostname in Windows Linux and Unix

Gambar
IP Address from hostname in Windows and Linux How many times in a day you have a hostname and you want to know the IP address? Hostname to IP address and IP address to hostname conversion is one of frequent thing which we need to do for many things when dealing with networking command in Unix. For one command we need an IP address for others we need hostname even from bash script sometimes we require a hostname and sometimes we look for IP address. networking commands are not as popular as find command or grep command but they are equally important and if you working in Windows or UNIX environment you must learn them and they should also be included in any list of Unix commands for beginners. By the way, In this hostname to IP address tutorial, I will show you how to get the IP address from hostname  or computer name in Unix or Linux and how to get hostname if you have an IP address . If you are looking for a way to do it via Java program then you can also see my post onhow to fi...

How to Create Complex directory Tree Using mkdir -p Command in UNIX

Gambar
One of the most common task in any Linux is creating directories, and most of us spend a lot of time creating complex directory structure in UNIX.  I am sure you know about mkdir command, we have been using this command in almost every operating system e..g DOS, Windows, Linux, OS/2, Solaris or many other *NIX operating system. It is one of the basic command but as important as find, grep or chmod.  mkdir stands for "make directory" and this command is literally used to create directories. Suppose, you need to create a directory tree like /opt/software/java/app/config, how are you going to create these directories? One by one right? Well, yes you can use mkdir and command to create these directories one by one as shown in below example : $ cd /opt $ mkdir software $ cd software $ mkdir java $ cd java $ mkdir app $ cd app $ pwd /opt/software/java/app/config This would take almost 8 commands to create above directory structure, unfortunately you just can not type mkdir /opt...

5 Articles to Learn about Shellshock Bash Bug

Gambar
The year of 2014 is looking like a year of biggest software bug and vulnerabilities. Earlier this year, internet was bleeding by Heartbleed vulnerability and now it's shocked by ShellShock bug. To me it looks like even bigger than Heartbleed, just because it's a bug in Bash Shell, our own bash shell, most popular among all UNIX shells like C and K. Given most of the servers in Investment banks, Insurance companies, Clouds and e-commerce domain are Linux Servers with bash being most used shell, impact is quite large. I am sure people with Microsoft stack is smiling somewhere :), but wait, read the full article. First details of Shellshock bug emerged Wednesday last week, since then it has gone viral, both online and offline. People are busy talking about it and engineers are busy patching Servers, computers, routers, firewalls and other computing resources using vulnerable versions of bash. It has triggered patching almost everywhere. I am sure many of my readers are still puzz...

10 Examples of tar command in UNIX and Linux

Gambar
tar command in UNIX or Linux is one of the important command which provides archiving functionality in unix. we can use UNIX tar command to create compressed or uncompressed archive files by using either gzip or bzip2. In this unix tar command tutorial we will see examples of unix tar command related to basic archiving task e.g. How to create tar archive in Unix and Linux , How to extract files from tar archive in unix, How to view contents of tar file in Unix and Linux or how to update and existing tar file in Unix. Examples of tar command in unix are kept simple and easy to understand and master each of the basic tasks using UNIX tar command . I thought about this article when I have writtenhow to be productive in UNIX and UNIX command tutorial and Example for beginners but somehow it gets delayed and now I am happy to see this published. Ok enough introduction now let's see some real-life examples of tar command in Unix and Linux : How to use tar command in Unix Using tar c...