Skip to main content

Working with basic linux commands

· 9 min read

Basic Linux commands

date

  • This command is used to display the system date and time. This information can be useful at times while writing scripts as well
    image.png
    command for displaying system date and time

cal

  • This command displays the current month's formatted calender on the terminal screen
    image.png
    command for calender

cd

  • cd command is also called as chdir which stands for change directory. We use this command to change or switch the currentt working directory. We can also navigate to directories by specifying absolute path from root directory
    image.png
    command for changing directory

cp

  • cp command is used to copy files or group of files or directories that create an exact image of a file on a disk with a different file name. We specify the path for the source files and the destination path where we want to have a copy of source files or directories
    image.png
    command for copying files and directories

whoami and who

  • whoami command is used to print the effective user ID whereas the who command prints information regarding users who are presently logged in.
    image.png
    command for displaying logged in users and current logged in user.

ls

  • ls command lists the current directory's files and directories along with the file types. We can modify the behavior of ls command by providing options like -l which shows the file permissions as well
    image.png
    command for listing files and directories

cat

  • cat command can be used to concatenate files and view the contents of a file in the terminal window as standard output
    image.png
    command for viewing contents of files

rm

  • This command is used to delete files
    image.png
    command for removing files

mkdir

  • mkdir command is used to create a new directory inside the current working directory
    image.png
    command for making directories

mv

  • mv command can be used to move files or directories from source directory to destination directory in our file system. mv command can also be used to rename files as well
    image.png
    command for moving files and directories

uname

  • uname command displays the current system's information. So when we type uname, we get the output as Linux which is the kernel for Kali Linux. With the uname -a, we can learn more about our system including kernel name, node name, kernel release, kernel version, hardware platform, processor and OS
    image.png
    command for system information

uptime

  • uptime command displays the amount of time the system has been running
    image.png
    command for shwoing uptime of system

users

  • this command is used to display the login names of users logged in on the system
    image.png
    command for all the logged in users on system

less

  • this command is used to view files instead of opening the file. The less command is a more powerful variant of the "more" command which is used to show information one page at a time to the terminal
    image.png command for viewing files, a better variant of more command

free

  • command provides us the useful information about the amount of RAM available on a Linux machine. It also displays the entire amount of physical memory used and available space, as well as swap memory with kernel buffers
    image.png
    command for showing info on memory space

more

  • command permits us to show output in the terminal one page at a time. This is particularly beneficial when using a command that requires a lot of scrolling
    image.png
    command for viewing file contents one page at a time

sort

  • We can sort the contents of file line by line. This command is useful when we have many lines of text in our file and we want to sort them in ascending or descending manner and write them to the standard output
    image.png
    command for sorting content of files line by line

history

  • This command prints the history of all the commands that have been entered by the current user.
    image.png
    command for showing command history

pwd

  • This command prints the current working directory, so if you are in root dir then it prints / and if you are in some other dir, then it prints the current working directory path from root.
    image.png
    command for printing current dirctory path

man

  • This command is used to display the user manual for all the commands in Linux. It includes the shell command the detailed synopsis with a short description about the command. The good thing about this is, we can view all the options which can modify the behavior of a command
    image.png
    image.png
    command for user manual

echo

  • This command requires any text as arguments, so that it prints it in the terminal. We can provide a text as a argument, or some other value to print as standard output. This command is useful for debugging shell programs
    image.png
    command for printing text in terminal as standard output

wget

  • This command downloads applications and web pages directly from the web. We provide a url on the web and this command downloads the specified resource, it can be a html file or a application
    image.png
    command for downloading files

tree

  • This command shows all of the contents in the current working directory. So the list of contents contains all of the files and folders and sub folders and their files as well. It does show all of the contents in the working directory in a nicely formatted tree format.
    image.png
    command for showing file structure in tree format

grep

  • This command searches files and prints the lines that match patterns. So we can provide a pattern such as a word, and grep command would search the file for the provided word and prints the lines in the file that contains the given word
    image.png
    command for searching files using a pattern and printing the lines that match the pattern

wc

  • wc command stands for word count. It shows the number of lines, words, characters and bytes.
    image.png
    command for counting word count

unzip

  • This command is used to extract files i.e unzip files from zip file.
    image.png
    command for unzipping zip files

du

  • du command is used to display the amount of disk space used by files and directories. So it shows how much space is being used in the disk space by each file and directory.
    image.png
    command for displaying amount of disk space used by files and directories

passwd

  • Command used to change the user password
    image.png
    command for changing password for user account

macchanger

  • macchanger changes your mac address, essentially changing your identity. It helps with protecting your anonymity on the internet, making your IP untraceable.
    image.png
    command for changing mac address

ifconfig

  • ifconfig <=> interface configuration. can be used for network interface configuration. It shows information about all the network adaptors, and we can also configure the network interface, like changing the IP address.
    image.png
    command for viewing and configuring network interfaces

ping

  • used to troubleshoot devices present in the network. it works by sending ICMP packets to the destination device which sends back response packets as well. The output shows the information about the packets sent and received and the time interval as well
    image.png
    command for testing network connectivity

nslookup

  • used to find the IP address of a domain or sub domain. So we provide the url as the argument and nslookup is going to provide us the IP of that domain
    image.png
    command for finding IP of a domain

ip

  • This command gives the details of all networks like ifconfig.This command can also be used to get the details of a specific interface.
    image.png
    command for displaying info on all networks interfaces.

route

  • Linux route command displays and manipulates the routing table existing for your system.A router is basically used to find the best way to send the packets across to a destination
    image.png
    command for viewing and configuring kernel routing file

host

  • Linux host command displays the domain name for a given IP address and IP address for a given hostname. It is also used to fetch DNS lookup for DNS related query.
    image.png
    command for displaying IP for given hostname

arp

  • Linux arp command stands for Address Resolution Protocol. It is used to view and add content to the kernel's ARP table.
    image.png
    command for viewing and configuring kernel's ARP table

iwconfig

  • Linux iwconfig is used to configure the wireless network interface. It is used to set and view the basic WI-FI details like SSID and encryption. Just like we have ifconfig, iwconfig is also used to view and configure network interfaces, but only for wireless adaptors.
    image.png
    command for viewing and configuring wireless network interfaces

hostname

  • Linux hostname is the simple command used to view and set the hostname of a system.
    image.png command for viewing and setting hostname of system

whois

  • Linux whois command is used to fetch all the information related to a website. You can get all the information about a website including the registration and the owner information.
    image.png
    command for fetching information about a website or domain.