• Home
  • Subscribe
  • Contribute Us
    • Share Your Interview Experience
  • Contact Us
  • About
    • About CSEstack
    • Campus Ambassador
  • Forum & Discus
  • Tools for Geek
  • LeaderBoard
CSEstack

What do you want to Learn Today?

  • Programming
    • Tutorial- C/C++
    • Tutorial- Django
    • Tutorial- Git
    • Tutorial- HTML & CSS
    • Tutorial- Java
    • Tutorial- MySQL
    • Tutorial- Python
    • Competitive Coding Challenges
  • CSE Subject
    • (CD) Compiler Design
    • (CN) Computer Network
    • (COA) Computer Organization & Architecture
    • (DBMS) Database Management System
    • (DS) Data Structure
    • (OS) Operating System
    • (ToA) Theory of Automata
    • (WT) Web Technology
  • Interview Questions
    • Interview Questions- Company Wise
    • Interview Questions- Coding Round
    • Interview Questions- Python
    • Interview Questions- REST API
    • Interview Questions- Web Scraping
    • Interview Questions- HR Round
    • Aptitude Preparation Guide
  • GATE 2022
  • Linux
  • Trend
    • Full Stack Development
    • Artificial Intelligence (AI)
    • BigData
    • Cloud Computing
    • Machine Learning (ML)
  • Write for Us
    • Submit Article
    • Submit Source Code or Program
    • Share Your Interview Experience
  • Tools
    • IDE
    • CV Builder
    • Other Tools …
  • Jobs

Most Useful Linux Commands You Need Everyday

Aniruddha Chaudhari/11241/0
Linux

What are the basic and most useful Linux commands you need every day to speed-up your execution?

In this tutorial, I am listing some of the important Linux commands that you will find very useful in your daily work routine.

One of the best things about Linux is that you will find many useful commands. Keeping those commands handy, you feel like doing a lot of things in just a few clicks.

If you get habitat using these useful Linux commands, gradually, your productivity will start increasing.

Without any ado, let’s see.

Note: I will keep this list updated with more of such useful commands as I come across.

Table of Contents

  • 1. Sort the Files and Directory by Time
  • 2. Change Current Directory Temporarily to Execute the Command
  • 3. Change the Permission for all the Files in Directory and Subdirectories
  • 4. Check Available, Cache and Free Memory
  • Some More Useful Linux Commands You Should Learn

1. Sort the Files and Directory by Time

How to sort the files and directory by Time?

The basic command to list all the files and directories inside the current directory path.

$ ls

You can also use the -l option with ls command to get more detail about each file and directory,

$ ls -l

Sample output:

Linux command to read file permission

Here,

  • “l” is for the long listing format. It shows detail about each directory like read/write permission, user, time and date of modification…

You can read more about Linux file permission.

In the above output image, you can see that the directories listed are not sorted.

If you want to sort the files by their modification time, you need to run the following command.

$ ls -lrt

Here,

  • “r” is to reverse the order of the directory listing. If you don’t use this parameter, it shows the directories in descending order of modification.
  • “t” is to sort the directories by modification time.

There are many options are available with the “ls” command to use. Refer Linux ls command tool to explore other options.

2. Change Current Directory Temporarily to Execute the Command

How to change the Current directory temporarily to execute the command?

Do you want to execute the command in a temporary directory in your bash?

Here is a simple command you can use to change the current directory temporarily and then execute your command.

We all the command to change the directory.

cd <your_directory_path>

After this command, your current directory will be changed permanently. You can check the current directory using pwd command.

Now, instead of changing directory permanently you can club cd command with the command you want to execute.

Syntax:

(cd <your_directory_path> && <your_command_to_execute>)

Don’t forget to enclose the commands inside the opening and closing bracket (parenthesis).

Rather than changing your directory, it executes the command in the directory you have mentioned.

Example:

Let check the current directory first.

$ pwd
/home/ani

Change the current directory temporarily and execute the command.

$ (cd /tmp && ls)

It will list out all the files in the /tmp directory.

$ pwd
/home/ani

You can see that the current directory is not changed.

Where you can use this command?

This command is very useful if you writing any script and you want to execute certain commands in a specific directory. You don’t need to change the current directory path.

3. Change the Permission for all the Files in Directory and Subdirectories

How to change the permission for all the files in directory and subdirectories?

Sometimes, while running the application you get permission denied issue. There can be multiple scripts in your project directory for which you don’t have permission to execute. Going to each script and giving permission is not convenient. Rather, you can set the permission for all the files in the project directory using a single command.

You can use a simple chmod command with the R attribute.

Go to the desired directory and run the following command.

chmod -R 777 *

Here,

  • Value 777 is numeric mode value to set read, write and execute permissions for all the files in the current directory and subdirectories.  (You should give the permission-based on your requirement.)
  • * is used to apply the changes to all the files.

You can learn more about how to calculate file permission values using the chmod calculator.

Calculate Linux File Permission Example

4. Check Available, Cache and Free Memory

You can use the free command to check the total, available, cache and free memory in Ubuntu (Linux).

Command:

free -h

The option ‘-h’ is used to print all the memory metrics in a human-readable format.

There are multiple options you can use with the free command.

Some More Useful Linux Commands You Should Learn

  • 7 Hostname Linux Commands to know more about your Linux host
  • Commands to find the size of each directory
  • Commands to mount/unmount devices

What are the useful Linux commands you use every day? Please mention in the comment, we will add it to this list.

Keep Wrestling and Start Learning Linux!

 

 

linux cmd
Aniruddha Chaudhari
I am complete Python Nut, love Linux and vim as an editor. I hold a Master of Computer Science from NIT Trichy. I dabble in C/C++, Java too. I keep sharing my coding knowledge and my own experience on CSEstack.org portal.

Your name can also be listed here. Got a tip? Submit it here to become an CSEstack author.

Leave a Reply Cancel reply

Make Your Linux Run Faster

Linux- Remove Old Kernels

Linux- Auto-Remove Unused Packages

Linux Commands

Linux- Most Useful Commands

Linux- LS command [Tool]

Linux- 7 Hostname Commands

Linux- Text Search in Terminal

Linux- File Permission [Chmod Calculator]

Linux- Check Free Memory in Ubuntu

Linux- Find Total Size of the Directory

Linux- Mount/Umount USB Drive

Linux- Change VNC Password

Linux- Get Serial Number (dmidecode)

Linux- Execute Shell Script

Linux Tools

5 Free Linux screenshot tools

Vim Editor Tricks

Vim- Setting Vim of Programming

Vim- 6 Commands to Edit File

Vim- Case-Sensitive Search

Vim- How to Create Function?

© 2022 – CSEstack.org. All Rights Reserved.

  • Home
  • Subscribe
  • Contribute Us
    • Share Your Interview Experience
  • Contact Us
  • About
    • About CSEstack
    • Campus Ambassador
  • Forum & Discus
  • Tools for Geek
  • LeaderBoard