Most useful Linux commands for daily 

# Display how long has the system been running – since tle last restart.


# List directory contents

ls /var/log/

# List files in directory but better attributes and human-readable

ls -ls 

# List files in directory sorted by file date/time.

ls -tlh 

# Change directory 

cd /var/log/ #will change current directory to /var/log/
cd ~ # the ~ character indicates the current logged in user's home directory. 

# Wildcards

When filtering for files or directories you can use * to match multiple files.

For example:

ls -lht /var/log/*log

This will list all files that have any name in the /var/log/ directory and their file names end with .log

#Show file contents, can concatenate multiple files contents.

cat /var/log/somefile.log
cat /var/log/*.log

# Sudo allows you to use super user commands under your username.

To be able to issue sudo commands a user must me a member of the wheel group – rhel related distributions.

sudo ls /var/log/

# See any changes made to a log file, display anything that is being appended.

tail -f /var/log/somefile
tail -30f /var/log/somefile

# Another way to monitor file changes is Less where you can press Ctrl+D to scroll up if you want to see more of previous changes. You quit less by pressing q on your keyboard.

less /var/log/somefile

# What is the name of the machine.


# For fqdn or long name

hostname -f 

# Help with a specific command

Any command can accept the –help parameter option to display help with that command’s options that are available.

ls --help
cd --help
tail --help 

# Find matches of a string in another string or file.

Here we cound for each file how many times the search text is found.

grep -1c "Power Button: Found keys" -f /var/log/*

# Using the pipe character | to combine commands in CLI (command line interface).

Here grep will help us filter the file contents and see only what we need. The command output from cat is sent to grep that displays the data.

sudo cat /var/log/secure | grep "COMMAND=/usr/bin/tail"


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.