Linux Commands You Should Know – Basics to Intermediate

What is Linux?

Just like Windows XP, Windows 7, Windows 8, and Mac OS X, Linux is an operating system. An operating system is a software that manages all of the hardware resources associated with your desktop or laptop. The operating system manages the communication between your software and your hardware. Without the operating system, the software wouldn’t function. We’ve got a great Newbie Guide for basic Linux commands that will teach you all you need to know.

Newbie Linux Commands

cd – Changes the current working directory in the command line console.

exit – Exits out of the current program, terminates the current command line terminal or logs you out of a Unix network depending on the context.

kill – Terminates the specified running process. The Linux version of Windows “End Process” in the task manager.

call – Display the calendar of the current month.

ls –i – To show the inode value of particular file/directory.

ls –a – Display the hidden files.

ls – List all of the contents of a specified directory. If no directory is specified, it will use the current directory.

man – There’s a running gag in the Linux community that man is the only command you need to know. It stands for manual, and it will give you detailed information on commands and aspects of Linux.

pwd – Displays the current working directory for the command line terminal. Good for when you’ve lost track of where you are in your system.

reboot – Immediately stops all running processes, shuts down the system, then reboots.

shutdown – Stops all running processes and shuts down the system. Parameters can be specified to issue a delayed shutdown or a shutdown at a particular time.

whoami – Tells you which user is logged in.

clear – Clears the terminal for you.

sudo – Runs commands as root,  which means no limitations due to permissions.

su – It’s of the basic Linux commands. ‘su’ is used to switch from one account to another.

Ping Use ping to check your connection to the server.

Help With almost every command, ‘–help’ option shows usage summary for that command.

wc This command counts lines, words, and letters of the input given to it.

history Use to view the search history.

clear history – Used to clear the recorded history.

System Information

date – Prints out the current system date and time. Specified parameters can change the format of the output.

alias – Aliases can be used for short names of commands. For example, you might use the clear command frequently. You can create an alias for it. (ex: alias c=“clear”)

find Use find from the command line to locate a specific file by name or extension

df  – Reports the disk space usage for the file system.

df –h –  Used to check the memory usage of the file system

df –ih –  It is used to calculate the inode usage of the file system.

df -h cmd result - Basic linux commands

df -h

hostname – Displays the name of the current host system.

ps – Displays information about all of the processes currently running on the system.

mount – The mount command mounts a storage device or filesystem, making it accessible and attaching it to an existing directory structure.

scp – SCP (secure copy) is a command line utility that allows you to securely copy files and directories between two locations

quota – Displays disk limits and current disk usage for a specified user. Useful when there are multiple users assigned to a particular system.

wget – It helps us to download the files from the web.

top – Displays all of the top processes in the system, by default sorted by CPU usage.

uptime – Reports how long the system has been running since last boot. Most useful for servers.

File Manipulation

bzip2 – Compresses specified contents into a .bz2 archive or extracts from a .bz2 archive depending on parameters.

chmod / chown – Changes the access permissions of one or more files (chmod) or changes the ownership of a particular file to a new user (chown). Only users with permission or ownership of a file can change that file’s permissions or ownership.

chgrp – Changes the access permissions to the group owner.

cp – Copies files to a new location with a new name depending on the parameters. Can copy directories too, whether recursively (includes all subdirectories) or not.

Head If you need to print first few lines of a file(any type) then you can use head command.

Tail It’s similar to the head command, but the function is opposite, prints last 10 lines of any file by default.

Md5sum You may often need to check if a file tampered with or not. However md5sum is not the safest

free –h The free command is used to display the amount of free and used RAM in the system, also prints the swap space stats.

find / locate  Searches the system starting at a specific directory and matching all files within that location to a set of conditions laid out by the command parameters. Very useful for quickly finding certain files.

install – Used in conjunction with Make files to copy files from one location to the system. Not to be confused with installing packages from a software repository.

mkdir / rmdir – Creates a directory (mkdir) or deletes a specified directory (rmdir). Directories can only be created and deleted within directories that you have permission in.

touch Touch command is to make a file command. It allows users to make file using Linux.

nautilus Used to view the directory in graphically.

mv – Moves files and directories to another location. Can be used to rename files and directories by keeping their source and destination locations the same.

ln – To create the hard link of the file.

ln –s – It creates a soft link of the file.

open – Opens a specified file using the default system application for files of its type.

rm – Remove and remove directory. Used to delete files and directories from the system, whether one at a time or in batch.

tar – Creates a .tar archive or extracts from a .tar archive depending on specified parameters.

zip / unzip – Create a .zip archive or extracts from a .zip archive depending on specified parameters.


Other Noteworthy Commands

apt-get – Advanced Packaging Tool. Use this command to install, remove, and configure software packages on your system. For a menu-based version, use aptitude command. Available on Debian-based Linux distributions.

ftp / sftp – Connects to a remote FTP server in order to download multiple files.

yum – Yellowdog Updater, Modified. An open source package manager used to easily install software packages from repositories. Available on RPM-compatible Linux distributions.

emacs – One of the most well-known text editors on Unix-like systems.

nano – A newbie-friendly command-line text editor that uses keyboard shortcuts to simulate menus.

vim Vim is the successor to Vi, both of which command line text editors for Unix-like systems. Though Vim is popular, it doesn’t use menus or icons for its interface so it has a reputation for being newbie-friendly.

cat Cat command allows us to create single or multiple files, view contain a file, concatenate files and redirect output in terminal or files.


Network Commands

nmcli connection show It used to show them, what are the network connection connected in your system/server.

nmcli connection show –active Used to show active network connection in your system/server.

nmcli connection add con-name name type ethernet i/f name eth0 To add the new network connection in your system/server.

nmcli connection up name(connection name)  Activate the particular connection.

nmtui To show graphically and set the network connection graphically.

ifconfig ifconfig utility is used to configure network interface parameters.

Grep Command in Linux

                        In basic Linux commands, grep filter searches a file for a particular pattern of characters, and displays all lines that contain that pattern. The pattern that is searched in the file is referred to as the regular expression (grep stands for a global search for a regular expression and print out).

grep – Searches through all of the files in a specified location trying to find files that contain lines that match a given string. Returns a list of all the files that scored a match.

–i “string” filename This is also a basic usage of the grep. This searches for the given string/pattern case-insensitively. So it matches all the words such as “the”, “THE” and “The” case insensitively.

grep –e “string” –e “string” filename It used for searching the multiple strings. –e is used to help for searching multiple strings.

^“string” filename The command used to searching for starting with particular word/string in particular file.

“string”$ filename This Linux command is used to searching for ending the particular word/string in particular file.

And also, Check this on How to Delete Files and Directory in Linux Commands