How to Choose the Best Open Source Software

After reading the O’Reilly book “Foundations for Architecting Data Solutions”, by Ted Malaska and Jonathan Seidman, I reflected on how I chose software/tools/solutions in the past and how I should choose them going forward.

As a bioinformatician you need to be able to quickly discern whether a publication/tool is really a major advancement or just marginally better. I’m not just talking about the newest single-cell RNA-seq technique or another file format, but for every problem case you have. Whether that be data visualization tools, presentation tools, distributed storage systems etc.

It’s not just about how useful the tool may be, it also depends on the quality of the documentation, how simple it is to install, where it sits in the open-source life cycle, etc.

Xkcd is funny but competing standards aren’t. Don’t believe me? Just look at how many pipeline tools exist!

When faced with so many options how can one choose the solutions that fit their need?

Why open source?

I’ve worked with a few licensed software solutions in the past; for example, BLAST2GO (plug: use dammit from Camille Scott instead!), Matlab, and an image stitching software called Autopano Giga (now defunct). One of my greatest frustrations was learning these tools only to later change roles and no longer have them available. As a consultant for the Department of Fisheries and Oceans the prohibitive cost of a Matlab was what pushed me over the edge into learning another high-level programming language — R. FWIW:

“[Matlab] They obfuscate their source code in many cases, meaning bugs are much harder to spot and impossible to edit ourselves without risking court action. Moreover, using Matlab for science results in paywalling our code. We are by definition making our computational science closed.” — excerpt from I Hate Matlab: How an IDE, a Language, and a Mentality Harm

Most companies eschew third party solutions or build their product as a hybrid of proprietary and open-source to keep their costs lower. For example, Amazon Web Services (AWS) offers it’s Simple Storage Service (Amazon S3) for a fee but is built upon open source software like Apache Hadoop. I’m not saying not to use AWS (or any other cloud provider) because sometimes you are constrained to having to; I actually used AWS for a project (transcriptome assembly of a coral species) with Docker. Currently I’m working with sensitive information that must be kept on-site, under lock-and-key, so alternative solutions are used.

Most of the newer big data platforms, and successful open-source projects began as internal projects at companies or universities for the first couple years before going through an external incubation phase. For example:

  • LinkedIn — “Apache Kafka
  • University of California at Berkeley — “Apache Spark
  • Cloudera — “Impala
  • Yahoo! — “Apache Hadoop
  • Google — “Kubernetes”
  • Facebook — “Apache Hive

There are benefits to choosing open-source projects backed by solid sponsors with good reputation, solid devs, and track record of sponsoring successful projects. You can be fairly confident that these projects have a solid codebase, great documentation, received session time at conferences, and considerable public recognition (through blog posts and articles surrounding it).

When considering open-source solutions it’s also important to gauge where they are in the open-source life cycle. According to Malaska and Seidman, there are nine (potential) stages in the project life cycle based on the Garnter Hype Cycle; however, I think only a few are relevant to discuss here:

Which Cycle Should You Choose?

Don’t believe the hype

This stage of the cycle is referred to as the “curing cancer” stage. The hype at this stage is important for attracting committers and contributors but unless you’re looking to help out in a major way you should steer clear. Unless you’re trying to be on the cutting edge (risk tolerance), or take on an active role as a contributor, it’s best to wait 6–12 months before trying any new technology. By letting others hit walls first you’ll encounter fewer bugs and have access to better documentation and blog posts.

A broken promise is not a lie

After the “curing cancer” stage is the broken promises stage. At this point people are using the project and are finding issues or limitations. For example, a solution may not integrate nicely with other existing systems or there may be problems with scaleability. You should treat any open source project at this stage with cautious optimism.

Go for dependable solutions whenever possible

Projects in the hardening or enterprise stage have become mature technologies. The amount of commits will signal the level of investment in a project. Tthe type of commits tell a story, telling where the author(s) are trying to go with the code, revealing what they want to do by signalling interest in different features of the project. By now the initial excitement has died down and there is more demand for stability than new features. The initial development team may be working on other projects as it has developed a solid community — this is often a good sign of success of a project.

Obviously recent activity signals that the project is alive and maintained. Remember that there are many dead and abandoned projects living on Github. That being said, activity doesn’t always need to be very recent! One prolific, “Rockstar Dev”, put it this way:

Context-switching is expensive, so if I worked on many packages at the same time, I’d never get anything done. Instead, at any point in time, most of my packages are lying fallow, steadily accumulating issues and ideas for new feature. Once a critical mass has accumulated, I’ll spend a couple of days on the package. — Hadley Wickham

Eventually projects enter the decline stage and no one wants to adopt or contribute to a dead or dying project.

Can i trust you?

I use R mostly so let me talk about where a project is hosted for a few moments. Code is often hosted on Github, ROpenSciBioconductor or CRAN. The Comprehensive R Archive Network (CRAN) was the main repository for R packages.

“As R users, we are spoiled. Early in the history of R, Kurt Hornik and Friedrich Leisch built support for packages right into R, and started the Comprehensive R Archive Network (CRAN). And R and CRAN had a fantastic run with. Roughly twenty years later, we are looking at over 12,000 packages which can (generally) be installed with absolute ease and no suprises. No other (relevant) open source language has anything of comparable rigour and quality.” — excerpt from Dirk Eddelbuettel

On CRAN packages of almost any type are welcome (as long as strict policies are met) and packages are tested daily (on multiple systems). rOpenSci is the perfect antithesis of CRAN. CRAN can be notoriously opaque, inconsistent, and aloof. It cannot deal with the volume of automation of CRAN but markets itself in terms of quality.

For the field of Bioinformatics Bioconductor is where a package will end up. Projects that exist solely on Github should be viewed with more caution as they have no checklists or peer-review.

Let’s talk about dependencies (a loaded topic — no pun intended)

Installing dependencies sucks! How often have you installed one package only to have a boatload pulled-in? You should try and avoid packages with many (changing) packages as this will be prohibitive to establish if your work is correct (hence ensuring reproducibility) because dependencies are hard to manage risks.

More dependencies means more edges between more nodes. Which eventually means more breakage.

Proponents of the tinyverse tend to stay away from bloated dependencies, no one wants to spend time in hell!

If you’re a developer remember:

Not all dependencies are equal … some popular packages [have] unstable APIs (a history of breaking changes) and high historic error rates (a history of complexity and adding features over fixing things).

You can also include a badge for your repo showing the number of dependencies your package relies on

Transparency is good

When looking at projects on Github you should look for people/packages with many stars, watchers, forks, contributors, etc. These visible cues of community support indicate the community cares about a person, project, or action and that many others would benefit from it.

Remember that the amount of commits, issues and pull-requests (PRs) can be a signal of investment and commitment to a project. Are the issues and PRs being dealt with? The latter is literally an offer of code that is being ignored rather than accepted, rejected or commented upon.

By following the actions on code, you can determine who founded the project, what happened across different releases and make inferences about the structure of the project and collaborator roles (who had expertise on which pieces of the system). Linked commits and issues communicates the reasoning behind a change to the code.

You can also gauge community interest by looking at the number of meetups,and conferences (and their attendance levels) , or at email lists, user groups, community forums etc.

Google trends can also be a good measure of the level of interest in projects or technologies.

Using metrics to track the decline of SPSS

Things to look for

  • Easy to install
  • Easy to run
  • Are there issues and PR raised

Is the owner taking care of them (fixing bugs, helping users, adding features)? or was it abandoned?

Does it list hardware requirements (RAM and disk size), example commands, toy data, example output, screenshots/recordit’s

For other things to look for see here and here.

Bench-marking

If you’re a software developer and considering incorporating one of a number of competing technologies you can perform internal benchmarks with your use cases and data.

If you’re using R there is different levels of magnification that a benchmark can provide. For a macro analysis (when computation is more intensive) you should use the rbenchmark package. For microscopic timing comparisons (e.g. nanoseconds elapsed) use the microbenchmark package

Sometimes other consortium’s will have already done the bench-marking for you (for example The Assemblathon”) . Nonetheless, one should be aware of hidden, or motivated biases trying to make unfair comparisons (use cases for which one tool clearly has an advantage). Also understand that testers could have been making an honest attempt at a fair test but made misunderstandings which lead to invalid results. Therefore it’s important to perform your own internal benchmarking and hold others benchmarks to an open standard of repeatability and verification.

Final words

Ultimately choosing a software solution comes down to the requirements of your project (the timeline, budget, and so forth), how willing are you to be on the cutting-edge (risk tolerance), and how capable team-members will be able to master these solutions based on their skill levels (internal skill set). Then, test out the solutions before fully committing. This job can be given to the prototyper role on your team; the person who likes experimenting/investigating new software.

 Source

20 Linux Command Tips and Tricks That Will Save You A Lot of Time

Brief: Here are some tiny but useful Linux commands, terminal tricks and shortcuts that will save you a lot of time while working with Linux command line.

Have you ever encountered a moment when you see your colleague using some simple Linux commands for tasks that took you several keystrokes? And when you saw that you were like, “Wow! I didn’t know it could have been done that easily”.

In this article, I’ll show you some pro Linux command tricks that will save you a lot of time and in some cases, from plenty of frustration. Not only your friends or colleagues will ‘wow’ at you, it will also help you increase your productivity as you will need fewer keystrokes and even fewer mouse clicks.

It’s not that these are Linux tips for beginners only. Chances are that even experienced Linux users will find some hidden gems that they were not aware despite using Linux for all these years.

In any case, you learn Linux by experience, be it your own or someone else’s 🙂

Cool Linux terminal tricks to save time and increase productivity

Linux command line tricks that will save your time

You might already know a few of these Linux command tips or perhaps all of it. In either case, you are welcome to share your favorite tricks in the comment section.

Some of these tips also depend on how the shell is configured. Let’s begin!

0. Using tab for autocompletion

I’ll start with something really obvious and yet really important: tab completion.

When you are starting to type something in Linux terminal, you can hit the tab key and it will suggest all the possible options that start with string you have typed so far.

For example, if you are trying to copy a file named my_best_file_1.txt, you can just type ‘cp m’ and hit tab to see the possible options.

Linux Command Line Tricks and Tips
Use tab for auto-completion

You can use tab in completing commands as well.

1. Switch back to the last working directory

Suppose you end up in a long directory path and then you move to another directory in a totally different path. And then you realize that you have to go back to the previous directory you were in. In this case, all you need to do is to type this command:

cd -

This will put you back in the last working directory. You don’t need to type the long directory path or copy paste it anymore.

Linux Command Line Tricks and Tips
Easily switch between directories

2. Go back to home directory

This is way too obvious. You can use the command below to move to your home directory from anywhere in Linux command-line:

cd ~

However, you can also use just cd to go back to home directory:

cd

Most modern Linux distributions have the shell pre-configured for this command. Saves you at least two keystrokes here.

Linux Command Line Tricks and Tips
Move to Home as quickly as possible

3. List the contents of a directory

You must be guessing what’s the trick in the command for listing the contents of a directory. Everyone knows to use the ls -l for this purpose.

And that’s the thing. Most people use ls -l to list the contents of the directory, whereas the same can be done with the following command:

ll

Again, this depends on the Linux distributions and shell configuration, but chances are that you’ll be able to use it in most Linux distributions.

Linux Command Line Tricks and Tips
Using ll instead of ls -l

4. Running multiple commands in one single command

Suppose, you have to run several commands one after another. Do you wait for the first command to finish running and then execute the next one?

You can use the ‘;’ separator for this purpose. This way, you can run a number of commands in one line. No need to wait for the previous commands to finish their business.

command_1; command_2; command_3

5. Running multiple commands in one single command only if the previous command was successful

In the previous command, you saw how to run several commands in one single command to save time. But what if you have to make sure that commands don’t fail?

Imagine a situation where you want to build a code and then if the build was successful, run the make?

You can use && separator for this case. && makes sure that the next command will only run when the previous command was successful.

command_1 && command_2

A good example of this command is when you use sudo apt update && sudo apt upgrade to upgrade your system.

6. Easily search and use the commands that you had used in the past

Imagine a situation where you used a long command couple of minutes/hours ago and you have to use it again. Problem is that you cannot remember the exact command anymore.

Reverse search is your savior here. You can search for the command in the history using a search term.

Just use the keys ctrl+r to initiate reverse search and type some part of the command. It will look up into the history and will show you the commands that matches the search term.

ctrl+r search_term

By default, it will show just one result. To see more results matching your search term, you will have to use ctrl+r again and again. To quit reverse search, just use Ctrl+C.

Linux Command Line Tricks and Tips
Reverse search in command history
Note that in some Bash shells, you can also use Page Up and Down key with your search term and it will autocomplete the command.

7. Unfreeze your Linux terminal from accidental Ctrl+S

You probably are habitual of using Ctrl+S for saving. But if you use that in Linux terminal, you’ll have a frozen terminal.

Don’t worry, you don’t have to close the terminal, not anymore. Just use Ctrl+Q and you can use the terminal again.

ctrl+Q

8. Move to beginning or end of line

Suppose you are typing a long command and midway you realize that you had to change something at the beginning. You would use several left arrow keystrokes to move to the start of the line. And similarly for going to the end of the line.

You can use Home and End keys here of course but alternatively, you can use Ctrl+A to go to the beginning of the line and Ctrl+E to go to the end.

Linux Command Line Tricks and Tips
Move to the beginning or end of the line

I find it more convenient than using the home and end keys, especially on my laptop.

9. Reading a log file in real time

In situations where you need to analyze the logs while the application is running, you can use the tail command with -f option.

tail -f path_to_Log

You can also use the regular grep options to display only those lines that are meaningful to you:

tail -f path_to_log | grep search_term

You can also use the option F here. This will keep the tail running even if the log file is deleted. So if the log file is created again, tail will continue logging.

10. Reading compressed logs without extracting

Server logs are usually gzip compressed to save disk space. It creates an issue for the developer or sysadmin analyzing the logs. You might have to scp it to your local and then extract it to access the files because, at times, you don’t have write permission to extract the logs.

Thankfully, z commands save you in such situations. z commands provide alternatives of the regular commands that you use to deal with log files such as less, cat, grep etc.

So you get zless, zcat, zgrep etc and you don’t even have to explicitly extract the compressed files. Please refer to my earlier article about using z commands to real compressed logs in detail.

This was one of the secret finds that won me a coffee from my colleague.

11. Use less to read files

To see the contents of a file, cat is not the best option especially if it is a big file. cat command will display the entire file on your screen.

You can use Vi, Vim or other terminal based text editors but if you just want to read a file, less command is a far better choice.

less path_to_file

You can search for terms inside less, move by page, display with line numbers etc.

12. Reuse the last item from the previous command with !$

Using the argument of the previous command comes handy in many situations.

Say you have to create a directory and then go into the newly created directory. There you can use the !$ options.

Linux Command Line Tricks and Tips
Use !$ to use the argument of last command
A better way to do the same is to use alt+. . You can use . a number times to shuffle between the options of the last commands.

13. Reuse the previous command in present command with !!

You can call the entire previous command with !!. This comes particularly useful when you have to run a command and realize that it needs root privileges.

A quick sudo !! saves plenty of keystrokes here.

Linux Command Line Tricks and Tips
Use !! to use last command as an argument

14. Using alias to fix typos

You probably already know what is an alias command in Linux. What you can do is, to use them to fix typos.

For example, you might often mistype grep as gerp. If you put an alias in your bashrc in this fashion:

alias gerp=grep

This way you won’t have to retype the command again.

15. Copy Paste in Linux terminal

This one is slightly ambiguous because it depends on Linux distributions and terminal applications. But in general, you should be able to copy paste commands with these shortcuts:

  • Select the text for copying and right click for paste (works in Putty and other Windows SSH clients)
  • Select the text for copying and middle click (scroll button on the mouse) for paste
  • Ctrl+Shift+C for copy and Ctrl+Shift+V for paste

16. Kill a running command/process

This one is perhaps way too obvious. If there is a command running in the foreground and you want to exit it, you can press Ctrl+C to stop that running command.

17. Using yes command for commands or scripts that need interactive response

If there are some commands or scripts that need user interaction and you know that you have to enter Y each time it requires an input, you can use Yes command.

Just use it in the below fashion:

yes | command_or_script

18. Empty a file without deleting it

If you just want to empty the contents of a text file without deleting the file itself, you can use a command similar to this:

> filename

19. Find if there are files containing a particular text

There are multiple ways to search and find in Linux command line. But in the case when you just want to see if there are files that contain a particular text, you can use this command:

grep -Pri Search_Term path_to_directory

I highly advise mastering find command though.

20. Using help with any command

I’ll conclude this article with one more obvious and yet very important ‘trick’, using help with a command or a command line tool.

Almost all command and command line tool come with a help page that shows how to use the command. Often using help will tell you the basic usage of the tool/command.

Just use it in this fashion:

command_tool --help

Your favorite Linux command line tricks?

I have deliberately not included commands like fuck because those are not standard commands that you’ll find everywhere. The tricks discussed here should be usable almost in all Linux distributions and shell without the need of installing a new tool.

I know that there are more Linux command tricks to save time in the terminal.

Source

How to Identify Working Directories Using Shell Characters and Variables

Some of the special directories that a Linux user is bound to work with so many times on a shell command line include the user’s home directory, the current and previous working directories.

Therefore, understanding how to easily access or pinpoint these directories using certain unique methods can be a bonus skill for a new or any Linux user.

Identify Working Directories Using Shell Characters and Environment Variables

Identify Working Directories Using Shell Characters and Environment Variables

In this tips for newbies, we shall look at ways of how a user can identify his/her home, current and previous working directories from the shell using special shell characters and environment variables.

1. Using Specific Shell Characters

There are certain specific characters that are understood by the shell when we are dealing with directories from the command line. The first character we shall look at is the tilde (~): it is used to access the current user’s home directory:

$ echo ~

Display User Home Directory

Display User Home Directory

Suggested Read: Learn ‘echo’ Command with This 15-Practical Examples

The second is the dot (.) character: it represents the current directory that a user is in, on the command line. In the screen shot below, you can see that the command ls and ls . produce the same out put, listing the contents of the current working directory.

$ ls
$ ls .

List Contents of Current Working Directory

List Contents of Current Working Directory

Suggested Read: Master ‘ls’ Command with This Basic 15-Practical Examples

The third special characters are the double dots (..) which represent the directory directly above the current working directory that a user is in.

In the image below, the directory above /var is the root directory (/), so when we use the ls command as follows, the contents of (/) are listed:

$ ls ..

Print Contents of Parent Directory

Print Contents of Parent Directory

Suggested Read: 7 Quirky ‘ls’ Command Tricks Every Linux User Should Know

2. Using Environmental Variables

Apart from the characters above, there are also certain environmental variables meant to work with the directories we are focusing on. In the next section, we shall walk through some of the important environmental variables for identifying directories from the command line.

$HOME: its value is the same as that of the tilde (~) character – the current user’s home directory, you can test that by using the echo command as follows:

$ echo $HOME

Print User Home Directory

Print User Home Directory

$PWD: in full, it stands for – Print Working Directory (PWD), as the name implies, it prints the absolute path of the current working directory in the shell command line as below:

$ echo $PWD 

Print Present Working Directory

Print Present Working Directory

$OLDPWD: it points to the directory a user was in, just before moving to the current working directory. You can access its value as below:

$ echo $OLDPWD

Print Parent Directory

Print Parent Directory

Suggested Read: 15 ‘pwd’ (Print Working Directory) Command Examples in Linux

3. Using Simple cd Commands

Additionally, you can also run some simple commands to quickly accessing your home directory and previous working directory. For example, when you are in any part of your file system on the command line, typing cdand hitting Enter will move you to your home directory:

$ echo $PWD
$ cd
$ echo $PWD

Switch to User Home Directory

Switch to User Home Directory

You can also move to the previous working directory using the command cd - command as below:

$ echo $PWD
$ echo $OLDPWD
$ cd - 
$ echo $PWD

Switch to Previous Working Directory

Switch to Previous Working Directory

In this post, we moved through some simple yet useful command line tips for new Linux users to identify certain special directories from within the shell command line.

Source

Install Htop 2.0 – Linux Process Monitoring for RHEL, CentOS & Fedora

This article is the continuation of our Linux system monitoring series, today we’re talking about the most popular monitoring tool called htop, which is just reached to version 2.0.2 and comes with some cool new features.

Htop Linux Process Monitoring Tool

Htop 2.0: Linux Process Monitoring

Htop is an interactive real time process monitoring application for Linux/Unix like systems and also a handy alternative to top command, which is default process monitoring tool that comes with pre-installed on all Linux operating systems.

Htop has numerous other user-friendly features, which are not available under top command and they are:

  1. In htop you can scroll vertically to view the full process list, and scroll horizontally to view the full command lines.
  2. It starts very quickly as compared top, because it doesn’t wait to fetch data during startup.
  3. In htop you can kill more than one processes at once without inserting their PIDs.
  4. In htop you no longer needed to enter process number or priority value to re-nice a process.
  5. Press “e” to print the set of environment variables for a process.
  6. Use mouse to select list items.

Install Htop Using Binary Packages in Linux

Important: Following binary installation, will give you the available htop version 1.0.3 or 1.0.2 in most distributions, so if you’re looking for Htop 2.0.2 version, then I recommend you to follow Source installation section as shown below:

To install Htop on RHEL 7/6/5 and CentOS 7/6/5, your system must have EPEL repository installed and enabled, to do so run the following commands on your respective distributions to install and enable it for your system architecture (32bit or 64bit).

On RHEL/CentOS – 32-bit OS

-------------- For RHEL/CentOS 6 --------------
# wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
# rpm -ihv epel-release-6-8.noarch.rpm

-------------- For RHEL/CentOS 5 --------------
# wget http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
# rpm -ihv epel-release-5-4.noarch.rpm

On RHEL/CentOS – 64-bit OS

-------------- For RHEL/CentOS 7 --------------
# wget dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm
# rpm -ihv epel-release-7-11.noarch.rpm 

-------------- For RHEL/CentOS 6 --------------
# wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -ihv epel-release-6-8.noarch.rpm

-------------- For RHEL/CentOS 5 --------------
# wget http://download.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
# rpm -ihv epel-release-5-4.noarch.rpm

Once EPEL repository has been installed, you can hit the following yum command to fetch and install the htop package as shown.

# yum install htop

On Fedora OS

Fedora users can easily install htop using Fedora Extras repository by typing:

# yum install htop
# dnf install htop      [On Fedora 22+ releases]

On Debian and Ubuntu

In Debian and Ubuntu, you can fetch htop by typing:

# sudo apt-get install htop

Compile and Install Htop from Source Packages

To install Htop 2.0.2 version, you must have Development Tools and Ncurses installed on your system, to do so run the following series of commands on your respective distributions.

On RHEL/CentOS and Fedora

# yum groupinstall "Development Tools"
# yum install ncurses ncurses-devel
# wget http://hisham.hm/htop/releases/2.0.2/htop-2.0.2.tar.gz
# tar xvfvz htop-2.0.2.tar.gz
# cd htop-2.0.2

On Debian and Ubuntu

$ sudo apt-get install build-essential  
$ sudo apt-get install libncurses5-dev libncursesw5-dev
$ wget http://hisham.hm/htop/releases/2.0.2/htop-2.0.2.tar.gz
$ tar xvfvz htop-2.0.2.tar.gz
$ cd htop-2.0.2

Next, run the configure and make script to install and compile htop.

# ./configure
# make
# make install

How do I use htop?

Now run the htop monitoring tool by executing following command on the terminal.

# htop

Htop is having three sections mainly

  1. Header, where we can see info like CPUMemorySwap and also shows tasks, load average and Up-time.
  2. List of processes sorted by CPU utilization.
  3. Footer shows different options like helpsetupfilter tree killnice , quit etc.

Htop Linux Processes Monitoring

Htop Linux Processes Monitoring

Press F2 or S for setup menu > there are four columns i.e SetupLeft ColumnRight Column and Available Meters.

Here, you can configure the meters printed at the top of the window, set various display options, select among color patterns and choose which columns are printed in which order.

Htop Setup Screen

Htop Setup Screen

Type tree or t to display processes tree view.

Htop Process View in Tree Format

Htop Process View in Tree Format

You can refer function keys displayed at footer to use this nifty htop application to monitor Linux running processes. However, we advise to use character keys or shortcut keys instead of function keys as it may have mapped with some other functions during secure connection.

Htop Shortcut and Function Keys

Some of the shortcut and function keys and its functionality to interact with htop.

Htop Command Shortcuts and Keys

Htop Command Shortcuts and Keys

Source

3 Command Line Tools to Install Local Debian (.DEB) Packages

In this tutorial we will learn how to install local software packages (.DEB) in Debian and its derivatives such as Ubuntu and Linux Mint using three different command line tools and they are dpkgapt and gdebi.

This is useful to those new users who have migrated from Windows to Ubuntu or Linux Mint. The very basic problem they face is installing local software on system.

However, Ubuntu and Linux Mint has its own Graphical Software Center for easy software installation, but we will be looking forward to installing packages through terminal way.

1. Install Software Using Dpkg Command

Dpkg is a package manager for Debian and its derivatives such as Ubuntu and Linux Mint. It is used to install, build, remove and manage .deb packages. but unlike other Linux package management systems, it cannot automatically download and install packages with their dependencies.

To install a local package, use the dpkg command with the -i flag along with package name as shown.

$ sudo dpkg -i teamviewer_amd64.deb

Install Local Package in Ubuntu

Install Local Package in Ubuntu

If you get any dependency errors while installing or after installing and launching a program, you can use the following apt command to resolve and install dependencies using the -f flag, which tells the program to fix broken dependencies.

$ sudo apt-get install -f

To remove a package use -r option or if you want to remove all its files including configuration files, you can purge it using the --purge option as shown.

$ sudo dpkg -r teamviewer       [Remove Package]
$ sudo dpkg --purge teamviewer  [Remove Package with Configuration Files]

Remove Package in Ubuntu

Remove Package in Ubuntu

To know more about installed packages, read our article that shows how to list all files installed from a .deb package.

2. Install Software Using Apt Command

The apt command is a advanced command-line tool, which offers new software package installation, existing software package upgradation, updating of the package list index, and even upgrading the whole Ubuntu or Linux Mint system.

It also offers apt-get and apt-cache command-line tools for managing packages more interactively on Debianand its derivatives such as Ubuntu and Linux Mint systems.

Essentially, apt-get or apt do not understand .deb files, they are designed to primarily handle package names (for example teamviewerapache2mariadb etc..) and they retrieve and install .deb archives associated with a package name, from a source specified in the /etc/apt/sources.list file.

The only trick to installing a local Debian package using apt-get or apt is by specifying a local relative or absolute path (./ if in current dir) to the package, otherwise it will try to retrieve the package from remote sources and the operation will fail.

$ sudo apt install ./teamviewer_amd64.deb
$ sudo apt-get install ./teamviewer_amd64.deb

Install Local Package Using apt in Ubuntu

Install Local Package Using apt in Ubuntu

Install Local Package Using apt-get in Ubuntu

Install Local Package Using apt-get in Ubuntu

To remove a package use remove option or if you want to remove all its files including configuration files, you can purge it using the purge option as shown.

$ sudo apt-get remove teamviewer
$ sudo apt-get purge teamviewer
OR
$ sudo apt remove teamviewer
$ sudo apt purge teamviewer

3. Install Software Using Gdebi Command

gdebi is a tiny command-line tool for installing local deb packages. It resolves and installs package dependencies on the fly. To install a package, use the following command.

$ sudo gdebi teamviewer_13.1.3026_amd64.deb

Install Local Packages Using Gdebi in Ubuntu

Install Local Packages Using Gdebi in Ubuntu

To remove a package installed from gdebi, you can use aptapt-get or dpkg commands using purge option as shown.

$ sudo apt purge teamviewer
OR
$ sudo apt-get purge teamviewer
OR
$ sudo dpkg --purge teamviewer

That’s It! In this tutorial, we have explained three different command line tools for installing or removing local Debian packages in Ubuntu and Linux Mint.

Source

3 Ways to Permanently and Securely Delete ‘Files and Directories’ in Linux

In most cases the means we use to delete a file from our computers such as using Delete key, Trash files or rm command, which do not permanently and securely remove the file from the hard disk (or any storage media).

The file is simply hidden from users and it resides somewhere on the hard disk. It can be recovered by data thieves, law enforcement or other threats.

Suggested Read: 3 Ways to Delete All Files in a Directory Except One or Few Files

Assuming a file contains classified or secret content such as usernames and passwords of a security system, an attacker with the necessary knowledge and skills can easily recover a deleted copy of the file and access these user credentials (and you can probably guess the aftermath of such as scenario).

In this article, we will explain a number of command line tools for permanently and securely deleting files in Linux.

1. Shred – Overwrite a File to Hide Content

shred overwrites a file to hide its contents, and can optionally delete it as well.

$ shred -zvu -n  5 passwords.list

In the command below, the options:

  1. -z – adds a final overwrite with zeros to hide shredding
  2. -v – enables display of operation progress
  3. -u – truncates and removes file after overwriting
  4. -n – specifies number of times to overwrite file content (the default is 3)
shred - overwrite a file to hide its contents

shred – overwrite a file to hide its contents

You can find more usage options and information in the shred man page:

$ man shred

2. Wipe – Securely Erase Files in Linux

A Linux wipe command securely erases files from magnetic memory and thereby making it impossible to recover deleted files or directory content.

First, you need to install wipe tool in order to it, run the appropriate command below:

$ sudo apt-get install wipe   [On Debian and its derivatives]
$ sudo yum install wipe       [On RedHat based systems]

The following command will destroy everything under the directory private.

$ wipe -rfi private/*

where the flags used:

  1. -r – tells wipe to recurse into subdirectories
  2. -f – enables forced deletion and disable confirmation query
  3. -i – shows progress of deletion process
Wipe - Securely Erase Files in Linux

Wipe – Securely Erase Files in Linux

Note: Wipe only works reliably on magnetic memory, therefore use the other methods for solid state disks (memory).

Read through the wipe man page for additional usage options and instructions:

$ man wipe

3. Secure-deletetion Toolkit for Linux

Secure-delete is a collection of secure file deletion tools, that contains srm (secure_deletion) tool, which is used to remove files securely.

First you need to install it using the relevant command below:

$ sudo apt-get install secure-delete   [On Debian and its derivatives]
$ sudo yum install secure-delete       [On RedHat based systems]

Once installed, you can use srm tool to remove files or directories securely on a Linux system as follows.

$ srm -vz private/*

where the options used:

  1. -v – enables verbose mode
  2. -z – wipes the last write with zeros instead of random data
srm - Securely Delete Files in Linux

srm – Securely Delete Files in Linux

Read through the srm man page for more usage options and information:

$ man srm

4. sfill -Secure Free Disk/Inode Space Wiper

sfill is a part of secure-deletetion toolkit, is a secure free disk and inode space wiper, it deletes files on free disk space in a secure method. sfill checks the the free space on the specified partition and fills it with random data from /dev/urandom.

The command below will execute sfill on my root partition, with the -v switch enabling verbose mode:

$ sudo sfill -v /home/aaronkilik/tmp/

Assuming you created a separate partition, /home to store normal system users home directories, you can specify a directory on that partition to apply sfill on it:

$ sudo sfill -v /home/username

The are a few limitations of sfill that you can read about in the man page, where you can also find additional usage flags and instructions:

$ man sfill

Note: These following two tools (sswap and sdmem) in the secure-deletetion toolkit are not directly relevant for the scope of this guide, however, we will explain them for knowledge purpose and future use.

5. sswap – Secure Swap Wiper

It is a secure partition wiper, sswap deletes data present on your swap partition in a secure manner.

Caution: remember to unmount your swap partition before using sswap! Otherwise your system might crash!

Simply determine you swap partition (and check if paging and swapping devices/files are turned on using swapon command), next, disable paging and swapping devices/files with swapoff command (renders swap partition unusable).

Then run sswap command on the swap partition:

$ cat /proc/swaps 
$ swapon
$ sudo swapoff /dev/sda6
$ sudo sswap /dev/sda6    #this command may take some time to complete with 38 default passes
sswap - Secure Swap Wiper

sswap – Secure Swap Wiper

Make an effort to read through the sswap man page for more usage options and information:

$ man sswap

6. sdmem – Secure Memory Wiper

sdmem is a secure memory wiper, it is designed to remove data present in your memory (RAM) in a secure manner.

It was originally named smem, but because on Debain systems there exists another package called smem – report memory consumption on per-process and per-user basis, the developer decided to rename it sdmem.

$ sudo sdmem -f -v

For more usage information, read through the sdmem man page:

$ man sdmem 

Suggested Read: PhotoRec – Recover Deleted or Lost Files in Linux

That’s it! In this article, we reviewed a number command line tools for permanently as well as securely deleting files in Linux.

 

11 Lesser Known Useful Linux Commands

Linux command line attracts most of the Linux Enthusiastic. A normal Linux user generally posses a vocabulary of roughly 50-60 commands to carry out their day-to-day task. Linux commands and their switches remains the most valuable treasure for a Linux-userShell-script programmer and Administrator. There are some Linux Commands which are lesser Known, yet very useful and handy irrespective of the fact whether you are a Novice or an Advanced User.

Lesser Known Linux Commands

Lesser Known Linux Commands

This very article aims at throwing light on some of the lesser known Linux commands which surely will help you to handle your Desktop/Server more efficiently.

1. sudo !! command

Running the command without specifying sudo command will give you permission denied error. So, you don’t need to rewrite the whole command again just put ‘!!‘ will grab the last command.

$ apt-get update

E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied) 
E: Unable to lock directory /var/lib/apt/lists/ 
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied) 
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
$ sudo !!

sudo apt-get update 
[sudo] password for server: 
…
..
Fetched 474 kB in 16s (28.0 kB/s) 
Reading package lists... Done 
server@localhost:~$

2. python command

The below command generates a simple web page over HTTP for the directory structure tree and can be accessed at port 8000 in browser till interrupt signal is sent.

# python -m SimpleHTTPServer

python -m SimpleHTTPServer

Directory Structure Tree

3. mtr Command

Most of us are familiar with ping and traceroute. How about combining the functionality of both the command into one with mtr command. In case mtr is not installed into your machine, apt or yum the required package.

$ sudo apt-get install mtr (On Debian based Systems)
# yum install mtr (On Red Hat based Systems)

Now run mtr command to start investigating the network connection between the host mtr runs on and google.com.

# mtr google.com

mtr command

mtr command

4. Ctrl+x+e Command

This command is very much useful for administrator and developers. To Automate day-to-day task an administrator needs to open editor by typing vivimnano, etc. How about firing instant editor (from terminal).

Just Press “Ctrl-x-e” from the terminal prompt and start working in editor.

Download Linux Command Line Cheat Sheet

Download Linux Command Line Book

5. nl Command

The “nl command” number the lines of a file. Number the lines of a file say ‘one.txt‘ with lines say (FedoraDebianArchSlack and Suse). First list the content of a file “one.txt” using cat command.

# cat one.txt 

fedora 
debian 
arch 
slack 
suse

Now run “nl command” to list them in a numbered fashion.

# nl one.txt 

1 fedora 
2 debian 
3 arch 
4 slack 
5 suse

6. shuf Command

The “shuf” command randomly select lines/files/folder from a file/folder. First list the contents of a folder using ls command.

# ls 

Desktop  Documents  Downloads  Music  Pictures  Public  Templates  Videos
#  ls | shuf (shuffle Input)

Music 
Documents 
Templates 
Pictures 
Public 
Desktop 
Downloads 
Videos
#  ls | shuf -n1 (pick on random selection)

Public
# ls | shuf -n1 

Videos
# ls | shuf -n1 

Templates
# ls | shuf -n1 

Downloads

Note: You can always replace ‘n1‘ with ‘n2‘ to pick two random selection or any other number of random selection using n3n4.

7. ss Command

The “ss” stands for socket statistics. The command investigates the socket and shows information similar to netstat command. It can display more TCP and state informations than other tools.

# ss 

State      Recv-Q Send-Q      Local Address:Port          Peer Address:Port   
ESTAB      0      0           192.168.1.198:41250        *.*.*.*:http    
CLOSE-WAIT 1      0               127.0.0.1:8000             127.0.0.1:41393   
ESTAB      0      0           192.168.1.198:36239        *.*.*.*:http    
ESTAB      310    0               127.0.0.1:8000             127.0.0.1:41384   
ESTAB      0      0           192.168.1.198:41002       *.*.*.*:http    
ESTAB      0      0               127.0.0.1:41384            127.0.0.1:8000

8. last Command

The “last” command show the history of last logged in users. This command searches through the file “/var/log/wtmp” and shows a list of logged-in and logged-out users along with tty’s.

#  last 
server   pts/0        :0               Tue Oct 22 12:03   still logged in   
server   tty8         :0               Tue Oct 22 12:02   still logged in   
…
...
(unknown tty8         :0               Tue Oct 22 12:02 - 12:02  (00:00)    
server   pts/0        :0               Tue Oct 22 10:33 - 12:02  (01:29)    
server   tty7         :0               Tue Oct 22 10:05 - 12:02  (01:56)    
(unknown tty7         :0               Tue Oct 22 10:04 - 10:05  (00:00)    
reboot   system boot  3.2.0-4-686-pae  Tue Oct 22 10:04 - 12:44  (02:39)    

wtmp begins Fri Oct  4 14:43:17 2007

9. curl ifconfig.me

So how do you obtain your External IP address? Using google?. Well the command output your external IP address right into your terminal.

# curl ifconfig.me

Note: You might don’t have curl package installed, you have to apt/yum to install package.

10. tree command

Get the current directory structure in tree like format.

# tree
. 
|-- Desktop 
|-- Documents 
|   `-- 37.odt 
|-- Downloads 
|   |-- attachments.zip 

|   |-- ttf-indic-fonts_0.5.11_all.deb 
|   |-- ttf-indic-fonts_1.1_all.deb 
|   `-- wheezy-nv-install.sh 
|-- Music 
|-- Pictures 
|   |-- Screenshot from 2013-10-22 12:03:49.png 
|   `-- Screenshot from 2013-10-22 12:12:38.png 
|-- Public 
|-- Templates 
`-- Videos 

10 directories, 23 files

11. pstree

This commands shows all the processes running currently along with associated child process, in a tree like format similar to ‘tree‘ command output.

# pstree 
init─┬─NetworkManager───{NetworkManager} 
     ├─accounts-daemon───{accounts-daemon} 
     ├─acpi_fakekeyd 
     ├─acpid 
     ├─apache2───10*[apache2] 
     ├─at-spi-bus-laun───2*[{at-spi-bus-laun}] 
     ├─atd 
     ├─avahi-daemon───avahi-daemon 
     ├─bluetoothd 
     ├─colord───{colord} 
     ├─colord-sane───2*[{colord-sane}] 
     ├─console-kit-dae───64*[{console-kit-dae}] 
     ├─cron 
     ├─cupsd 
     ├─2*[dbus-daemon] 
     ├─dbus-launch 
     ├─dconf-service───2*[{dconf-service}] 
     ├─dovecot─┬─anvil 
     │         ├─config 
     │         └─log 
     ├─exim4 
     ├─gconfd-2 
     ├─gdm3─┬─gdm-simple-slav─┬─Xorg 
     │      │                 ├─gdm-session-wor─┬─x-session-manag─┬─evolution-a+ 
     │      │                 │                 │                 ├─gdu-notific+ 
     │      │                 │                 │                 ├─gnome-scree+ 
     │      │                 │                 │                 ├─gnome-setti+ 
     │      │                 │                 │                 ├─gnome-shell+++ 
     │      │                 │                 │                 ├─nm-applet──+++ 
     │      │                 │                 │                 ├─ssh-agent 
     │      │                 │                 │                 ├─tracker-min+ 
     │      │                 │                 │                 ├─tracker-sto+ 
     │      │                 │                 │                 └─3*[{x-sessi+ 
     │      │                 │                 └─2*[{gdm-session-wor}] 
     │      │                 └─{gdm-simple-slav} 
     │      └─{gdm3} 
     ├─6*[getty] 
     ├─gnome-keyring-d───9*[{gnome-keyring-d}] 
     ├─gnome-shell-cal───2*[{gnome-shell-cal}] 
     ├─goa-daemon───{goa-daemon} 
     ├─gsd-printer───{gsd-printer} 
     ├─gvfs-afc-volume───{gvfs-afc-volume}

That’s all for now. In the next article of mine I would cover certain other lesser known Linux commands which would be fun. Till then stay tuned and connected to Tecmint. Like and share us and help us get spread.

Read Also:

  1. 10 Lesser Known Linux Commands – Part 2
  2. 10 Lesser Known Commands for Linux – Part 3
  3. 10 Lesser Known Effective Linux Commands – Part IV
  4. 10 Lesser Known Useful Linux Commands- Part V

10 Lesser Known Linux Commands – Part 2

Continuing the last conversation from 11 Lesser Known Useful Linux Commands – Part I here in this article we will be focusing on other lesser known Linux commands, that will prove to be very much useful in managing Desktop and Server.

Lesser Known Linux Commands

10 Lesser Known Linux Commands

12. <space> Command

Every piece of command you type in terminal gets recorded in the history and can be retried using historycommand.

How about cheating history command? Yeah you can do it and its very easy. Just put one or more white space before typing a command in terminal and your command wont be recorded.

Lets give it a try, we will try five common Linux commands (say lspwdunameecho “hi” and who) in terminal after one white space and check if these commands are docked in history or not.

avi@localhost:~$  ls
avi@localhost:~$  pwd
avi@localhost:~$  uname
avi@localhost:~$  echo “hi”
avi@localhost:~$  who

Now run ‘history‘ command to see whether these above executed commands are recorded or not.

avi@localhost:~$ history

   40  cd /dev/ 
   41  ls 
   42  dd if=/dev/cdrom1 of=/home/avi/Desktop/squeeze.iso 
   43  ping www.google.com 
   44  su

You see our last executed commands are not logged. we can also cheat history by using an alternate command ‘cat | bash‘ of-course without quotes, in the same way as above.

13. stat Command

The stat command in Linux displays the status information of a file or filesystem. The stat shows a whole lot of information about the file which name is passed as argument. Status Information includes file SizeBlocksAccess PermissionDate-time of file last access, Modifychange, etc.

avi@localhost:~$ stat 34.odt 

  File: `34.odt' 
  Size: 28822     	Blocks: 64         IO Block: 4096   regular file 
Device: 801h/2049d	Inode: 5030293     Links: 1 
Access: (0644/-rw-r--r--)  Uid: ( 1000/     avi)   Gid: ( 1000/     avi) 
Access: 2013-10-14 00:17:40.000000000 +0530 
Modify: 2013-10-01 15:20:17.000000000 +0530 
Change: 2013-10-01 15:20:17.000000000 +0530

14. <alt>. and <esc>.

The above key combination is not actually a command but a tweak which put the last command argument at prompt, in the order of last entered command to previous entered command. Just press and hold ‘Alt‘ or ‘Esc‘ and continue pressing ‘.‘.

Download Linux Command Line Cheat Sheet

Download Linux Command Line Book

15. pv command

You might have seen simulating text in Movies specially Hollywood Movies, where the text appears as if it is being typed in the Real time. You can echo any kind of text and output in simulating fashion using ‘pv‘ command, as pipelined above. The pv command might not be installed in your system, and you have to apt or yum the required packages to install ‘pv‘ into your box.

root@localhost:# echo "Tecmint [dot] com is the world's best website for qualitative Linux article" | pv -qL 20
Sample Outpit
Tecmint [dot] com is the world's best website for qualitative Linux article

16. mount | column -t

The above command shows the list of all the mounted filesystem in a nice formatting with specification.

avi@localhost:~$ mount | column -t
Sample Outpit
/dev/sda1    on  /                         type  ext3         (rw,errors=remount-ro) 
tmpfs        on  /lib/init/rw              type  tmpfs        (rw,nosuid,mode=0755) 
proc         on  /proc                     type  proc         (rw,noexec,nosuid,nodev) 
sysfs        on  /sys                      type  sysfs        (rw,noexec,nosuid,nodev) 
udev         on  /dev                      type  tmpfs        (rw,mode=0755) 
tmpfs        on  /dev/shm                  type  tmpfs        (rw,nosuid,nodev) 
devpts       on  /dev/pts                  type  devpts       (rw,noexec,nosuid,gid=5,mode=620) 
fusectl      on  /sys/fs/fuse/connections  type  fusectl      (rw) 
binfmt_misc  on  /proc/sys/fs/binfmt_misc  type  binfmt_misc  (rw,noexec,nosuid,nodev) 
nfsd         on  /proc/fs/nfsd             type  nfsd         (rw)

17. Ctr+l command

Before going further, let me ask you how you clear your terminal. Hmmm! You type “clear” at prompt. Well the above command perform the action of cleaning your terminal all at a once. Just press “Ctr+l” and see how it clears your terminal all at once.

18. curl command

How about checking your unread mail from the command line. This command is very useful for those who work on headless server. Again it asks for password at run time and you need not hard code your password in the above line, which is otherwise a security risk.

avi@localhost:~$ curl -u avishek1210@gmail.com --silent "https://mail.google.com/mail/feed/atom" | perl -ne 'print "\t" if //; print "$2\n" if /<(title|name)>(.*)<\/>/;'
Sample Outpit
Enter host password for user 'avishek1210@gmail.com': 
Gmail - Inbox for avishek1210@gmail.com 
People offering cars in Delhi - Oct 26 
	Quikr Alerts 
another dependency question 
	Chris Bannister 
	Ralf Mardorf 
	Reco 
	Brian 
	François Patte 
	Curt 
	Siard 
	berenger.morel 
Hi Avishek - Download your Free MBA Brochure Now... 
	Diya 
★Top Best Sellers Of The Week, Take Your Pick★ 
	Timesdeal 
aptitude misconfigure? 
	Glenn English 
Choosing Debian version or derivative to run Wine when resource poor 
	Chris Bannister 
	Zenaan Harkness 
	Curt 
	Tom H 
	Richard Owlett 
	Ralf Mardorf 
	Rob Owens

19. screen Command

The screen command makes it possible to detach a long running process from a session that can again be reattached, as and when required which provides flexibility in command execution.

To run a process (long) we generally execute as

avi@localhost:~$ ./long-unix-script.sh

Which lacks flexibility and needs the user to continue with the current session, however if we execute the above command as.

avi@localhost:~$ screen ./long-unix-script.sh

It can be de-attached or re-attached in different sessions. When a command is executing press “Ctrl + A” and then “d” to de-attach. To attach run.

avi@localhost:~$ screen -r 4980.pts-0.localhost

Note: Here, the later part of this command is screen id, which you can get using ‘screen -ls‘ command. To know more about ‘screen command‘ and their usage, please read our article that shows some useful 10 screen commands with examples.

20. file

No! the above command is not a typo. ‘file‘ is a command which gives you information about the type of file.

avi@localhost:~$ file 34.odt 

34.odt: OpenDocument Text

21. id

The above command print real and effective user and group ids.

avi@localhost:~$ id
Sample Output
uid=1000(avi) gid=1000(avi) 
groups=1000(avi),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev),109(netdev),111(bluetooth),117(scanner)

That’s all for now. Seeing the success of last article of this series and this very article, I’ll be coming with another part of this article containing several other Lesser Known Linux commands very soon. Till then Stay Tuned and connected to Tecmint. Don’t Forget to provide us with your value-able Feedback in Comments.

Read Also

  1. 10 Lesser Known Commands for Linux – Part 3
  2. 10 Lesser Known Effective Linux Commands – Part IV
  3. 10 Lesser Known Useful Linux Commands- Part V

10 Lesser Known Commands for Linux – Part 3

Overwhelmed with the response of last two articles of “Lesser Known Linux Article” series namely.

  1. 11 Lesser Known Useful Linux Commands – Part I
  2. 10 Lesser Known Linux Commands – Part 2
  3. 10 Lesser Known Effective Linux Commands – Part IV
  4. 10 Lesser Known Useful Linux Commands- Part V

Lesser Known Linux Commands

10 Lesser Known Linux Commands

We have come up with the third article of this series which includes few other lesser known Linux commands, worth knowing. May be you are already aware of these commands, no doubt you are an experienced Linux user and loves exploration.

22. ^foo^bar Command

Run the last command with modification, in a single instance. Suppose I need to run a command ‘ls -l‘ to long list the content of a directory say ‘Desktop’. Accidentally, you type ‘lls -l‘. So now you will have to retype the whole command or edit the previous command using navigation key. That is painful when the command is long.

avi@localhost:~/Desktop$ lls -l 

bash: lls: command not found
avi@localhost:~/Desktop$ ^lls^ls 

ls -l 
total 7489440 

drwxr-xr-x 2 avi  avi       36864 Nov 13  2012 101MSDCF 
-rw-r--r-- 1 avi  avi      206833 Nov  5 15:27 1.jpg 
-rw-r--r-- 1 avi  avi      158951 Nov  5 15:27 2.jpg 
-rw-r--r-- 1 avi  avi       90624 Nov  5 12:59 Untitled 1.doc

Note: In the above replacement we used “^typo(to be replaced)^original_command”. This command may be very dangerous if you knowingly or unknowingly replaced the typo with system command or anything risky say rm -rf.

23. > file.txt Command

This command flush the contents of a file without the need of removing and creating the same file again. This command is very useful in scripting language when we need an output or log on the same file again and again.

I have a file say ‘test.txt’ on my ‘Desktop‘ with a lot of text.

avi@localhost:~/Desktop$ cat test.txt 

Linux 
GNU 
Debian 
Fedora 
kali 
ubuntu 
git 
Linus 
Torvalds
avi@localhost:~/Desktop$ > test.txt 
avi@localhost:~/Desktop$ cat test.txt

Note: Again, this command can be dangerous, don’t ever try to flush the contents of a system file or configuration file. If you do so, you will be in serious trouble.

24. at Command

The ‘at‘ command is similar to cron command and can be used for scheduling a task or command to run at specified time.

avi@localhost:~/Desktop$ echo "ls -l > /dev/pts/0" | at 14:012

OR

avi@localhost:~/Desktop$ echo "ls -l > /dev/pts/0" | at 2:12 PM
Sample Output
-rw-r--r-- 1 avi  avi      220492 Nov  1 13:49 Screenshot-1.png 
-rw-r--r-- 1 root root        358 Oct 17 10:11 sources.list 
-rw-r--r-- 1 avi  avi  4695982080 Oct 10 20:29 squeeze.iso 
..
..
-rw-r--r-- 1 avi  avi       90624 Nov  5 12:59 Untitled 1.doc 
-rw-r--r-- 1 avi  avi       96206 Nov  5 12:56 Untitled 1.odt 
-rw-r--r-- 1 avi  avi        9405 Nov 12 23:22 Untitled.png

Note: echo “ls -l” : This string echo’s the command (here ls -l) on standard terminal. You can replace ‘ls -l‘ with any command of your need and choice.

> : redirects the output

The /dev/pts/0 : This is the output device and/or file, where output is sought, here the output is at terminal.

In my case, my tty is at /dev/pts/0, at that time. You can check your tty by running command tty.

avi@localhost:~/Desktop$ tty 

/dev/pts/0

Note: The ‘at‘ command execute the task as soon as the system clock matches the specified time.

25. du -h –max-depth=1 Command

The below command outputs the size of sub-folders within the current directory, in human readable format.

avi@localhost:/home/avi/Desktop# du -h --max-depth=1 

38M	./test 
1.1G	./shivji 
42M	./drupal 
6.9G	./101MSDCF 
16G	.

Note: The above command can be very much useful in checking system disk usage.

Download Linux Command Line Cheat Sheet

Download Linux Command Line Book

26. expr Command

The ‘expr‘ command is not that much lesser known command. This command is very much useful in carrying out simple mathematical calculation in terminal.

avi@localhost:/home/avi/Desktop# expr 2 + 3 
5
avi@localhost:/home/avi/Desktop# expr 6 – 3 
3
avi@localhost:/home/avi/Desktop# expr 12 / 3 
4
avi@localhost:/home/avi/Desktop# expr 2 \* 9 
18

27. look Command

Check for words from English dictionary in case of confusion, from the terminal itself. Viz., I am a bit confused if the spelling is carrier or carieer.

avi@localhost:/home/avi/Documents# look car 

Cara 
Cara's 
…
... 
carps 
carpus 
carpus's 
carrel 
carrel's 
carrels 
carriage 
carriage's 
carriages 
carriageway 
carriageway's 
carried 
carrier 
carrier's 
carriers 
carries 
…
... 
caryatids

The above command showed all the words from dictionary starting with string ‘car’. I got what I was searching for.

28. yes Command

Another command which is not used frequently on regular basis, normally but is very useful in scripting language and for system Administrators.

This command continues to print a given string, till interrupt instruction is given by you.

avi@localhost:~/Desktop$ yes "Tecmint is one of the best site dedicated to Linux, how to" 

Tecmint is one of the best site dedicated to Linux, how to 
Tecmint is one of the best site dedicated to Linux, how to 
Tecmint is one of the best site dedicated to Linux, how to 
Tecmint is one of the best site dedicated to Linux, how to 
…
…
...
Tecmint is one of the best site dedicated to Linux, how to 
Tecmint is one of the best site dedicated to Linux, how to 
Tecmint is one of the best site dedicated to Linux, how to

29. factor Command

The factor command is actually a command of mathematical origin. This command outputs all the factors of a given number.

avi@localhost:~/Desktop$ factor 22 
22: 2 11
avi@localhost:~/Desktop$ factor 21 
21: 3 7
avi@localhost:~/Desktop$ factor 11 
11: 11

30. ping -i 60 -a IP_address

All of us use ping command to check is server is live or not. And I usually ping google, to check if I am connected to internet or not.

It is sometimes irritating, when you wait and keep watching your terminal to get reply of ping command or say, wait for server to get connected.

How about an audible sound as soon as the server comes live.

avi@localhost:~/Desktop$ ping -i 60 -a www.google.com 

PING www.google.com (74.125.200.103) 56(84) bytes of data. 
64 bytes from www.google.com (74.125.200.103): icmp_req=1 ttl=44 time=105 ms 
64 bytes from 74.125.200.103: icmp_req=2 ttl=44 time=281 ms

Let me tell you one thing, before you report that the command didn’t return any audible sound. Make sure your system audio is not mute, sound theme must be enabled in ‘sound preferences‘ and make sure ‘Enable window and window sound‘ is checked.

31. tac Command

This command is very interesting which prints the content of a text file in reverse order, i.e., from last line to first line.

I have a text file 35.txt in my Documents directory, under home folder. Checking it’s content using cat command.

avi@localhost:~/Documents$ cat 35.txt
Sample Output
1. Linux is built with certain powerful tools, which are unavailable in windows. 

2. One of such important tool is Shell Scripting. Windows however comes with such a tool but as usual it is much weak as compared to it's Linux Counterpart. 

3.Shell scripting/programming makes it possible to execute command(s), piped to get desired output in order to automate day-to-day usages.

Now reverse the content of file using tac command.

avi@localhost:~/Documents$ tac 35.txt
Sample Output
3.Shell scripting/programming makes it possible to execute command(s), piped to get desired output in order to automate day-to-day usages. 

2. One of such important tool is Shell Scripting. Windows however comes with such a tool but as usual it is much weak as compared to it's Linux Counterpart. 

1. Linux is built with certain powerful tools, which are unavailable in windows.

That’s all for now. If you are aware of other lesser known Linux commands, you can put a comment, so that we can include those in our future articles.

10 Lesser Known Effective Linux Commands – Part IV

Continuing the Lesser Known series, this fourth article of the series will let you know some useful funny and animated commands. Here we go into the practical session, without much theory.

10 Lesser Known Effective Commands

10 Lesser Known Effective Commands

  1. 11 Lesser Known Useful Linux Commands – Part I
  2. 10 Lesser Known Linux Commands – Part 2
  3. 10 Lesser Known Commands for Linux – Part 3
  4. 10 Lesser Known Useful Linux Commands- Part V

In the fourth article of this series which includes few other lesser known Linux commands, worth knowing. Might be you’re already aware of these commands, no doubt you’re an experienced Linux user and loves exploration.

32. strace Command

The strace is a debugging tool which is used primarily for troubleshooting purpose in Linux. It might not be installed by default in your system and you may need to apt or yum the required package.

Trace a command execution using strace command:

root@tecmint [~]# strace pwd
Sample Output
execve("/bin/pwd", ["pwd"], [/* 29 vars */]) = 0
brk(0)                                  = 0x728000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0df2000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=38427, ...}) = 0
mmap(NULL, 38427, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f29b0de8000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3, "7ELF
execve("/bin/pwd", ["pwd"], [/* 29 vars */]) = 0
brk(0)                                  = 0x728000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0df2000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=38427, ...}) = 0
mmap(NULL, 38427, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f29b0de8000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\355\1I;\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1922152, ...}) = 0
mmap(0x3b49000000, 3745960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3b49000000
mprotect(0x3b4918a000, 2093056, PROT_NONE) = 0
mmap(0x3b49389000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x189000) = 0x3b49389000
mmap(0x3b4938e000, 18600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3b4938e000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de7000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de6000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de5000
....
execve("/bin/pwd", ["pwd"], [/* 29 vars */]) = 0
brk(0)                                  = 0x728000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0df2000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=38427, ...}) = 0
mmap(NULL, 38427, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f29b0de8000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\355\1I;\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1922152, ...}) = 0
mmap(0x3b49000000, 3745960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3b49000000
mprotect(0x3b4918a000, 2093056, PROT_NONE) = 0
mmap(0x3b49389000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x189000) = 0x3b49389000
mmap(0x3b4938e000, 18600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3b4938e000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de7000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de6000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de5000
....
execve("/bin/pwd", ["pwd"], [/* 29 vars */]) = 0
brk(0)                                  = 0x728000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0df2000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=38427, ...}) = 0
mmap(NULL, 38427, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f29b0de8000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\355\1I;\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1922152, ...}) = 0
mmap(0x3b49000000, 3745960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3b49000000
mprotect(0x3b4918a000, 2093056, PROT_NONE) = 0
mmap(0x3b49389000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x189000) = 0x3b49389000
mmap(0x3b4938e000, 18600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3b4938e000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de7000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de6000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de5000
....
execve("/bin/pwd", ["pwd"], [/* 29 vars */]) = 0
brk(0)                                  = 0x728000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0df2000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=38427, ...}) = 0
mmap(NULL, 38427, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f29b0de8000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\355\1I;\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1922152, ...}) = 0
mmap(0x3b49000000, 3745960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3b49000000
mprotect(0x3b4918a000, 2093056, PROT_NONE) = 0
mmap(0x3b49389000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x189000) = 0x3b49389000
mmap(0x3b4938e000, 18600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3b4938e000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de7000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de6000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de5000
....
execve("/bin/pwd", ["pwd"], [/* 29 vars */]) = 0
brk(0)                                  = 0x728000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0df2000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=38427, ...}) = 0
mmap(NULL, 38427, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f29b0de8000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\355\1I;\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1922152, ...}) = 0
mmap(0x3b49000000, 3745960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3b49000000
mprotect(0x3b4918a000, 2093056, PROT_NONE) = 0
mmap(0x3b49389000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x189000) = 0x3b49389000
mmap(0x3b4938e000, 18600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3b4938e000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de7000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de6000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de5000
....
execve("/bin/pwd", ["pwd"], [/* 29 vars */]) = 0
brk(0)                                  = 0x728000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0df2000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=38427, ...}) = 0
mmap(NULL, 38427, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f29b0de8000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\355\1I;\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1922152, ...}) = 0
mmap(0x3b49000000, 3745960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3b49000000
mprotect(0x3b4918a000, 2093056, PROT_NONE) = 0
mmap(0x3b49389000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x189000) = 0x3b49389000
mmap(0x3b4938e000, 18600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3b4938e000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de7000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de6000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de5000
....
execve("/bin/pwd", ["pwd"], [/* 29 vars */]) = 0
brk(0)                                  = 0x728000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0df2000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=38427, ...}) = 0
mmap(NULL, 38427, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f29b0de8000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\355\1I;\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1922152, ...}) = 0
mmap(0x3b49000000, 3745960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3b49000000
mprotect(0x3b4918a000, 2093056, PROT_NONE) = 0
mmap(0x3b49389000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x189000) = 0x3b49389000
mmap(0x3b4938e000, 18600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3b4938e000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de7000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de6000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de5000
....
execve("/bin/pwd", ["pwd"], [/* 29 vars */]) = 0
brk(0)                                  = 0x728000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0df2000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=38427, ...}) = 0
mmap(NULL, 38427, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f29b0de8000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\355\1I;\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1922152, ...}) = 0
mmap(0x3b49000000, 3745960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3b49000000
mprotect(0x3b4918a000, 2093056, PROT_NONE) = 0
mmap(0x3b49389000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x189000) = 0x3b49389000
mmap(0x3b4938e000, 18600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3b4938e000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de7000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de6000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de5000
....
execve("/bin/pwd", ["pwd"], [/* 29 vars */]) = 0
brk(0)                                  = 0x728000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0df2000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=38427, ...}) = 0
mmap(NULL, 38427, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f29b0de8000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\355\1I;\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1922152, ...}) = 0
mmap(0x3b49000000, 3745960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3b49000000
mprotect(0x3b4918a000, 2093056, PROT_NONE) = 0
mmap(0x3b49389000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x189000) = 0x3b49389000
mmap(0x3b4938e000, 18600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3b4938e000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de7000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de6000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de5000
....
>
execve("/bin/pwd", ["pwd"], [/* 29 vars */]) = 0
brk(0)                                  = 0x728000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0df2000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=38427, ...}) = 0
mmap(NULL, 38427, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f29b0de8000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\355\1I;\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1922152, ...}) = 0
mmap(0x3b49000000, 3745960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3b49000000
mprotect(0x3b4918a000, 2093056, PROT_NONE) = 0
mmap(0x3b49389000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x189000) = 0x3b49389000
mmap(0x3b4938e000, 18600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3b4938e000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de7000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de6000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de5000
....
execve("/bin/pwd", ["pwd"], [/* 29 vars */]) = 0
brk(0)                                  = 0x728000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0df2000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=38427, ...}) = 0
mmap(NULL, 38427, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f29b0de8000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\355\1I;\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1922152, ...}) = 0
mmap(0x3b49000000, 3745960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3b49000000
mprotect(0x3b4918a000, 2093056, PROT_NONE) = 0
mmap(0x3b49389000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x189000) = 0x3b49389000
mmap(0x3b4938e000, 18600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3b4938e000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de7000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de6000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de5000
....
execve("/bin/pwd", ["pwd"], [/* 29 vars */]) = 0
brk(0)                                  = 0x728000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0df2000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=38427, ...}) = 0
mmap(NULL, 38427, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f29b0de8000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\355\1I;\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1922152, ...}) = 0
mmap(0x3b49000000, 3745960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3b49000000
mprotect(0x3b4918a000, 2093056, PROT_NONE) = 0
mmap(0x3b49389000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x189000) = 0x3b49389000
mmap(0x3b4938e000, 18600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3b4938e000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de7000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de6000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de5000
....
execve("/bin/pwd", ["pwd"], [/* 29 vars */]) = 0
brk(0)                                  = 0x728000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0df2000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=38427, ...}) = 0
mmap(NULL, 38427, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f29b0de8000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\355\1I;\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1922152, ...}) = 0
mmap(0x3b49000000, 3745960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3b49000000
mprotect(0x3b4918a000, 2093056, PROT_NONE) = 0
mmap(0x3b49389000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x189000) = 0x3b49389000
mmap(0x3b4938e000, 18600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3b4938e000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de7000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de6000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de5000
....
05I;
execve("/bin/pwd", ["pwd"], [/* 29 vars */]) = 0
brk(0)                                  = 0x728000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0df2000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=38427, ...}) = 0
mmap(NULL, 38427, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f29b0de8000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\355\1I;\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1922152, ...}) = 0
mmap(0x3b49000000, 3745960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3b49000000
mprotect(0x3b4918a000, 2093056, PROT_NONE) = 0
mmap(0x3b49389000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x189000) = 0x3b49389000
mmap(0x3b4938e000, 18600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3b4938e000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de7000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de6000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de5000
....
execve("/bin/pwd", ["pwd"], [/* 29 vars */]) = 0
brk(0)                                  = 0x728000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0df2000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=38427, ...}) = 0
mmap(NULL, 38427, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f29b0de8000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\355\1I;\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1922152, ...}) = 0
mmap(0x3b49000000, 3745960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3b49000000
mprotect(0x3b4918a000, 2093056, PROT_NONE) = 0
mmap(0x3b49389000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x189000) = 0x3b49389000
mmap(0x3b4938e000, 18600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3b4938e000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de7000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de6000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de5000
....
execve("/bin/pwd", ["pwd"], [/* 29 vars */]) = 0
brk(0)                                  = 0x728000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0df2000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=38427, ...}) = 0
mmap(NULL, 38427, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f29b0de8000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\355\1I;\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1922152, ...}) = 0
mmap(0x3b49000000, 3745960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3b49000000
mprotect(0x3b4918a000, 2093056, PROT_NONE) = 0
mmap(0x3b49389000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x189000) = 0x3b49389000
mmap(0x3b4938e000, 18600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3b4938e000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de7000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de6000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de5000
....
"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0755, st_size=1922152, ...}) = 0 mmap(0x3b49000000, 3745960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3b49000000 mprotect(0x3b4918a000, 2093056, PROT_NONE) = 0 mmap(0x3b49389000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x189000) = 0x3b49389000 mmap(0x3b4938e000, 18600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3b4938e000 close(3) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de7000 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de6000 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f29b0de5000 ....

The strace command accepts a lot of arguments and have many options. Refer to man page for detailed information.

33. disown -a && exit Command

Most of the system administrators use screen command to control jobs running in the terminal background. Let’s say if you having a long running job and want to detach from the terminal, you use screen command to do it. But what if you don’t know how to use screen, here comes disown command to rescue.

The disown command is used to run the jobs continuously in the background even after you closing the terminal session. The syntax of the disown command is:

root@tecmint [~]# Command; disown -a && exit

To detach again the long running job in the terminal, use the jobs command to find the job number and then use disown %n where n is the job number. To verify actually the job is running use ps or top command. The nohupcommand is an alternative to the disown command.

34. getconf LONG_BIT Command

The above command shows your machine architecture if it is 32 bit or 64 bit?

root@tecmint [~]# getconf LONG_BIT

32

Download Linux Command Line Cheat Sheet

Download Linux Command Line Book

35. Display Date on the Terminal

The below command is a combination of several commands, better say it a script. For a person working at shell or terminal, without GUI seeing current system date is tedious job. You have to type ‘date‘ command to check today’s date.

Just execute the below command on you prompt and see the date and time on the above right corner of terminal.

root@tecmint [~]# while sleep 1;do tput sc;tput cup 0 $(($(tput cols)-29));date;tput rc;done &

Show Date in Terminal

Show Date in Terminal

36. convert Command

While writing tutorial, I usually need to produce output, many a times in image format. The above command combination does this for me. Say I need the output of tree command (for /etc/x11 directory) in image format. What I did at terminal was:

root@tecmint:/etc/X11# tree | convert label:@- /home/avi/tree.png

The output of the above command can be seen at the specified location (here, home directory of mine) with the file name specified as tree.png.

37. watch -t -n1 “date +%T|figlet”

Remember our description of “figlet” command in our earlier article “20 Funny Commands of Linux”. This command was very cool, this time we will be pipelining ‘figlet‘ to show animated digital clock in the terminal.

Just check-out yourself, remember you must have figlet installed on the system, do apt or yum to install the required package.

root@tecmint [~]# watch -t -n1 "date +%T|figlet"
Sample Output
 _  ___    ____   ___    _____ _  _                                                                                             Fri Nov 29 10:29:34 GMT 
/ |/ _ \ _|___ \ / _ \ _|___ /| || |
| | | | (_) __) | (_) (_) |_ \| || |_
| | |_| |_ / __/ \__, |_ ___) |__   _|
|_|\___/(_)_____|  /_/(_)____/   |_|

38. host and dig Commands

Although “host” and “dig” command is not that much lesser known, still not very frequently used. The host command is DNS lookup utility.

root@tecmint [~]# host www.google.com

www.google.com has address 173.194.66.147
www.google.com has address 173.194.66.105
www.google.com has address 173.194.66.99
www.google.com has address 173.194.66.104
www.google.com has address 173.194.66.106
www.google.com has address 173.194.66.103
www.google.com has IPv6 address 2a00:1450:400c:c03::68
root@tecmint [~]# dig www.google.com

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6_4.6 <<>> www.google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<

39. dstat Command

The dstat is a versatile tool, that generates statistics relating to system resource. By default your system might not have ‘dstat‘ installed. Do a apt or yum to install ‘dstat‘ before using this very colorful and description system resource generator.

root@tecmint [~]# dstat

dstat command

dstat command

40. bind -p Command

The ‘bind -p‘ command will show all the shortcuts available for BASH shell.

root@tecmint [~]# bind -p
Sample Output
"\C-g": abort 
"\C-x\C-g": abort 
"\e\C-g": abort 
"\C-j": accept-line
"\C-m": accept-line 
# alias-expand-line (not bound) 
# arrow-key-prefix (not bound) 
# backward-byte (not bound) 
"\C-b": backward-char 
"\eOD": backward-char 
"\e[D": backward-char 
"\e!": complete-command 
"\e/": complete-filename 
"\e@": complete-hostname 
"\e{": complete-into-braces 
"\e~": complete-username 
"\e$": complete-variable 
# copy-backward-word (not bound)
# copy-forward-word (not bound) 
# copy-region-as-kill (not bound)
....
....

41. touch /forcefsck

The above command will create an empty folder ‘forcefsck‘, under root directory. This will force Linux System to check the file system on the very next boot.

root@tecmint [~]# touch /forcefsck

That’s all for Now. You People are loving these ‘Lesser Known Commands‘ and hence we are continuing the series, the next article of this series will be available very soon.

Till then stay tuned and connected to Tecmint. Don’t forget to give your valuable feedback in our comment section. Do a favor to us, Like and share us and help us spread.

10 Lesser Known Useful Linux Commands- Part V

After four highly appreciated and such a successful series of Articles on “Lesser Known Linux Commands” we are here presenting you the last article on this series, obviously not the least. The previous articles are:

Lesser Known Linux Commands

Lesser Known Linux Commands

  1. 11 Lesser Known Useful Linux Commands – Part I
  2. 10 Lesser Known Linux Commands – Part II
  3. 10 Lesser Known Commands for Linux – Part III
  4. 10 Lesser Known Effective Linux Commands – Part IV

42. lsb_release

The command ‘lsb_release‘ print distribution-specific information. If lsb_release is not installed, you can apt ‘lsb-core‘ on Debian or yum ‘redhat-lsb‘ on Red Hat the package.

# lsb_release -a

LSB Version:    :base-4.0-ia32:base-4.0-noarch:core-4.0-ia32:core-4.0-noarch:graphics-4.0-ia32:
Distributor ID: CentOS
Description:    CentOS release 6.3 (Final)
Release:        6.3
Codename:       Final

Note: Option ‘-a‘, shows all the available information in respect of versioniddescriptionrelease and codename.

43. nc -zv localhost 80

Check if port 80 is open or not. We can replace ‘80‘ with any other port number to check if it is opened or closed.

$ nc -zv localhost 80

Connection to localhost 80 port [tcp/http] succeeded!

Check if port 8080 is open or not.

$ nc -zv localhost 8080

nc: connect to localhost port 8080 (tcp) failed: Connection refused

44. curl ipinfo.io

The below command will output the ‘Geographical Location‘ of the IP address, provided.

$ curl ipinfo.io 

"ip": "xx.xx.xx.xx",
"hostname": "triband-del-aa.bbb.cc.ddd.bol.net.in",
"city": null,
"region": null,
"country": "IN",
"loc": "20,77",
"org": "AS17813 Mahanagar Telephone Nigam Ltd."

45. find . -user root

The below command output the files with respect of the user (root) owned files. All the files owned by user ‘root’ in the current directory.

# find . -user root

./.recently-used.xbel
./.mysql_history
./.aptitude
./.aptitude/config
./.aptitude/cache
./.bluefish
./.bluefish/session-2.0
./.bluefish/autosave
./.bash_history

All the files owned by user ‘avi‘ in the current directory.

# find . -user avi

./.cache/chromium/Cache/f_002b66
./.cache/chromium/Cache/f_001719
./.cache/chromium/Cache/f_001262
./.cache/chromium/Cache/f_000544
./.cache/chromium/Cache/f_002e40
./.cache/chromium/Cache/f_00119a
./.cache/chromium/Cache/f_0014fc
./.cache/chromium/Cache/f_001b52
./.cache/chromium/Cache/f_00198d
./.cache/chromium/Cache/f_003680

46. sudo apt-get build-dep ffmpeg

The below command will build the dependency, automatically during the corresponding package installation. Hence the process of package installation is very much fluent and easy.

# apt-get build-dep ffmpeg

libxinerama-dev libxml-namespacesupport-perl libxml-sax-expat-perl
libxml-sax-perl libxml-simple-perl libxrandr-dev libxrender-dev
x11proto-render-dev x11proto-xinerama-dev xulrunner-dev
The following packages will be upgraded:
libpixman-1-0
1 upgraded, 143 newly installed, 0 to remove and 6 not upgraded.
Need to get 205 MB of archives.
After this operation, 448 MB of additional disk space will be used.
Do you want to continue [Y/n]?

47. lsof -iTCP:80 -sTCP:LISTEN

The below command outputs, name of process/service using a specific port 80. To better understand run the following command on port 80, it will list all services/processes running on port.

root@localhost:/home/avi# lsof -iTCP:80 -sTCP:LISTEN

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
apache2 1566 root 5u IPv6 5805 0t0 TCP *:www (LISTEN)
apache2 1664 www-data 5u IPv6 5805 0t0 TCP *:www (LISTEN)
apache2 1665 www-data 5u IPv6 5805 0t0 TCP *:www (LISTEN)
apache2 1666 www-data 5u IPv6 5805 0t0 TCP *:www (LISTEN)
apache2 1667 www-data 5u IPv6 5805 0t0 TCP *:www (LISTEN)
apache2 1668 www-data 5u IPv6 5805 0t0 TCP *:www (LISTEN)

Same way, you can also check the running services/processes of port 22.

root@localhost:/home/avi# lsof -iTCP:22 -sTCP:LISTEN

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
sshd 2261 root 3u IPv4 8366 0t0 TCP *:ssh (LISTEN)
sshd 2261 root 4u IPv6 8369 0t0 TCP *:ssh (LISTEN)

48. find -size +100M

The find command lists all the files in the current directory above the specified size (here 100 MB), recursively.

# find -size +100M

./.local/share/Trash/files/linuxmint-15-cinnamon-dvd-32bit.iso
./Downloads/Fedora-Live-Desktop-i686-19-1.iso
./Downloads/Ant Videos/shakira 2.avi
./Downloads/Deewar.avi
./Desktop/101MSDCF/MOV02224.AVI
./Desktop/101MSDCF/MOV02020.AVI
./Desktop/101MSDCF/MOV00406.MP4
./Desktop/squeeze.iso

Listing all the files whose size if more than 1000 MB, within current directory, recursively.

root@localhost:/home/avi# find -size +1000M

./Downloads/The Dark Knight 2008 hindi BRRip 720p/The Dark Knight.mkv.part
./Downloads/Saudagar - (1991) - DVDRiP - x264 - AAC 5.1 - Chapters - Esubs - [DDR]/Saudagar 
- (1991) - DVDRiP - x264 - AAC 5.1 - Chapters - Esubs - [DDR].mkv
./Downloads/Deewar.avi
./Desktop/squeeze.iso

49. pdftk

The pdftk command merges several pdf files into one. You must have installed pdftk program. If not, do apt or yum to get the required package.

$ pdftk 1.pdf 2.pdf 3.pdf …. 10.pdf cat output merged.pdf

50. ps -LF -u user_name

The below command outputs processes and threads of a user. The option “L” (list threads) and “-F” (Full Format Listing).

$ ps -LF -u avi

avi 21645 3717 21766 0 5 66168 117164 1 18:58 ? 00:00:00 /usr/
avi 21645 3717 21768 0 5 66168 117164 1 18:58 ? 00:00:00 /usr/
avi 22314 3717 22314 0 2 42797 50332 0 19:00 ? 00:00:40 /usr/
avi 22314 3717 22316 0 2 42797 50332 1 19:00 ? 00:00:00 /usr/
avi 22678 24621 22678 0 1 969 1060 1 21:05 pts/1 00:00:00 ps -L
avi 23051 3717 23051 0 2 37583 45444 1 19:03 ? 00:00:52 /usr/
avi 23051 3717 23053 0 2 37583 45444 0 19:03 ? 00:00:03 /usr/
avi 23652 1 23652 0 2 22092 12520 0 19:06 ? 00:00:22 gnome
avi 23652 1 23655 0 2 22092 12520 0 19:06 ? 00:00:00 gnome

51. Startx — :1

Sharing X session, means frequently logging in and out, this is where the Startx command comes to rescue. The command creates a new session thus no need to login and logout frequently from a session. In order to switch between the two X session, we need to switch between ‘ctrl+Alt+F7‘ and ‘ctrl+Alt+F8‘.

Note: The keys “ctrl+Alt+F1“, “ctrl+Alt+F6” is for console session, and “ctrl+Alt+F7“, “ctrl+Alt+F12” is for X session. Hence 6 console session and 6 X session, without frequent logging-in and out. The above sequence works on most of the distro, however different distro may have implemented it differently. I have checked it on Debian, and it works perfectly fine.

That’s all for now.

Source

How To Assign Output of a Linux Command to a Variable

When you run a command, it produces some kind of output: either the result of a program is suppose to produce or status/error messages of the program execution details. Sometimes, you may want to store the output of a command in a variable to be used in a later operation.

In this post, we will review the different ways of assigning the output of a shell command to a variable, specifically useful for shell scripting purpose.

To store the output of a command in a variable, you can use the shell command substitution feature in the forms below:

variable_name=$(command)
variable_name=$(command [option ...] arg1 arg2 ...)
OR
variable_name='command'
variable_name='command [option ...] arg1 arg2 ...'

Below are a few examples of using command substitution.

In this first example, we will store the value of who (which shows who is logged on the system) command in the variable CURRENT_USERS user:

$ CURRENT_USERS=$(who)

Then we can use the variable in a sentence displayed using the echo command like so:

$ echo -e "The following users are logged on the system:\n\n $CURRENT_USERS"

In the command above: the flag -e means interpret any escape sequences ( such as \n for newline) used. To avoid wasting time as well as memory, simply perform the command substitution within the echo command as follows:

$ echo -e "The following users are logged on the system:\n\n $(who)"

Shows Current Logged Users in Linux

Shows Current Logged Users in Linux

Next, to demonstrate the concept using the second form; we can store the total number of files in the current working directory in a variable called FILES and echo it later as follows:

$ FILES=`sudo find . -type f -print | wc -l`
$ echo "There are $FILES in the current working directory."

Show Number of Files in Directory

Show Number of Files in Directory

That’s it for now, in this article, we explained the methods of assigning the output of a shell command to a variable. You can add your thoughts to this post via the feedback section below.

Source

How to Undo or Redo a Yum Install on CentOS and RHEL

One of the most important and useful feature added to YUM Package Manager (from version 3.2.25) is the ‘yum history’ command. It allows you to review a full history of yum transactions that have been run on a system.

It shows the dates and times when a transactions were performed, whether the transactions succeeded or were aborted, the number of packages affected, and so much more.

Importantly, yum history can be used to undo or redo certain transactions. In this article, we will show how to undo or redo a yum install including dependencies on a CentOS/RHEL distribution.

To do this, first you need to review the yum transactions history by running the following command as root user, otherwise use the sudo command to gain root privileges.

$ sudo yum history  
OR
$ sudo yum history list all

List Yum History

List Yum History

From the output in the screenshot above, the yum history shows you the transaction ID, the command line, date and time, action and more.

To undo a yum install, take note of the transaction ID, and perform the required action. In this example, we want to undo the install with ID 63, which will erase the package that was installed in the specified transaction, as follows (enter y/yes when asked).

$ sudo yum history undo 63

Undo Yum Install Package

Undo Yum Install Package

To redo a yum install, as before, take note of the transaction ID, and run it. For instance to redo the install with ID 63, run the the following command.

$ sudo yum history redo 63

Note that you can do the same for a yum remove/erase transaction. The most important thing to note is the transaction ID of an yum install or yum remove action.

For more information about yum history, see this guide:

  1. How to Use ‘Yum History’ to Find Out Installed or Removed Packages Info

That’s all for now! In this article, we demonstrated how to undo or redo a yum install including dependencies on CentOS/RHEL. Share your thoughts with us via the comment form below.

Source

11 Ways to Find User Account Info and Login Details in Linux

This article will show you eleven useful ways to find the information about users on a Linux system. Here we’ll describe commands to get a user’s account details, show login details as well as what users are doing on the system.

Read AlsoHow to Monitor Linux Commands Executed by System Users in Real-time

If you want to add users in Linux, use the useradd utility, and to modify or change any attributes of a already created user account, use the usermod via the command line as explained in the following guides:

  1. 15 Useful Practical Examples on ‘useradd’ Command
  2. 15 Useful Practical Examples on ‘usermod’ Command

We’ll start by looking at commands to find a user’s account information, then proceed to explain commands to view login details.

1. id Command

id is a simple command line utility for displaying a real and effective user and group IDs as follows.

$ id tecmint 

uid=1000(tecmint) gid=1000(tecmint) groups=1000(tecmint),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),113(lpadmin),130(sambashare)

2. groups Command

groups command is used to show all the groups a user belongs to like this.

$ groups tecmint

tecmint : tecmint adm cdrom sudo dip plugdev lpadmin sambashare

3. finger Command

finger command is used to search information about a user on Linux. It doesn’t come per-installed on many Linux systems.

To install it on your system, run this command on the terminal.

$ sudo apt install finger	#Debian/Ubuntu 
$ sudo yum install finger	#RHEL/CentOS
$ sudo dnf install finger	#Fedora 22+

It shows a user’s real name; home directory; shell; login: name, time; and so much more as below.

$ finger tecmint

Login: tecmint        			Name: TecMint
Directory: /home/tecmint            	Shell: /bin/bash
On since Fri Sep 22 10:39 (IST) on tty8 from :0
   2 hours 1 minute idle
No mail.
No Plan.

4. getent Command

getent is a command line utility for fetching entries from Name Service Switch (NSS) libraries from a specific system database.

To get a user’s account details, use the passwd database and the username as follows.

$ getent passwd tecmint

tecmint:x:1000:1000:TecMint,,,:/home/tecmint:/bin/bash

5. grep Command

grep command is a powerful pattern searching tool available on most if not all Linus systems. You can use it to find information about a specific user from the system accounts file: /etc/passwd as shown below.

$ grep -i tecmint /etc/passwd

tecmint:x:1000:1000:TecMint,,,:/home/tecmint:/bin/bash

6. lslogins Command

lslogins command shows information about known users in the system, the -u flag only displays user accounts.

$ lslogins -u

UID USER       PROC PWD-LOCK PWD-DENY LAST-LOGIN GECOS
   0 root        144                              root
1000 tecmint      70                     10:39:07 TecMint,,,
1001 aaronkilik    0                              
1002 john          0                              John Doo

7. users Command

users command shows the usernames of all users currently logged on the system like so.

$ users

tecmint
aaron

8. who Command

who command is used to display users who are logged on the system, including the terminals they are connecting from.

$ who -u

tecmint  tty8         2017-09-22 10:39 02:09        2067 (:0)

9. w Command

w command shows all users who are logged on the system and what they are doing.

$ w

12:46:54 up  2:10,  1 user,  load average: 0.34, 0.44, 0.57
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
tecmint  tty8     :0               10:39    2:10m  4:43   0.46s cinnamon-sessio

10. last or lastb commands

last/lastb commands displays a list of last logged in users on the system.

$ last 
OR
$ last -a   #show hostname on the last column
List of Last Logged Users
tecmint  tty8         Fri Sep 22 10:39    gone - no logout  :0
reboot   system boot  Fri Sep 22 10:36   still running      4.4.0-21-generic
tecmint  tty8         Thu Sep 21 10:44 - down   (06:56)     :0
reboot   system boot  Thu Sep 21 10:42 - 17:40  (06:58)     4.4.0-21-generic
tecmint  tty8         Wed Sep 20 10:19 - down   (06:50)     :0
reboot   system boot  Wed Sep 20 10:17 - 17:10  (06:52)     4.4.0-21-generic
tecmint  pts/14       Tue Sep 19 15:15 - 15:16  (00:00)     tmux(14160).%146
tecmint  pts/13       Tue Sep 19 15:15 - 15:16  (00:00)     tmux(14160).%145
...

To show all the users who were present at a specified time, use the -p option as follows.

$ last -ap now

tecmint  tty8         Fri Sep 22 10:39    gone - no logout  :0
reboot   system boot  Fri Sep 22 10:36   still running      4.4.0-21-generic

wtmp begins Fri Sep  1 16:23:02 2017

11. lastlog Command

lastlog command is used to find the details of a recent login of all users or of a given user as follows.

$ lastlog  
OR
$ lastlog -u tecmint 	#show lastlog records for specific user tecmint
Records of Recent Logged Users
Username         Port     From             Latest
root                                       **Never logged in**
kernoops                                   **Never logged in**
pulse                                      **Never logged in**
rtkit                                      **Never logged in**
saned                                      **Never logged in**
usbmux                                     **Never logged in**
mdm                                        **Never logged in**
tecmint          pts/1    127.0.0.1        Fri Jan  6 16:50:22 +0530 2017
..

That’s it! If you know any other command-line trick or command to view user account details do share with us.

You’ll find these related article so useful:

  1. How to Manage Users and Groups in Linux
  2. How to Delete User Accounts with Home Directory in Linux
  3. 3 Ways to Change Default User Shell in Linux
  4. How to Block or Disable User Logins in Linux

In this article, we’ve explained various ways to find information about users and login details on a Linux system.

 
Source

WP2Social Auto Publish Powered By : XYZScripts.com