All commands in linux ubuntu

40+ most used Ubuntu 22.04 Commands

Ubuntu 22.04 Commands

The world of Ubuntu welcomes you and it is ready to grant you all the power over your system. However, being a newbie, you might find its Command Line Interface (CLI) a little intimidating. A lot of people find Linux more challenging as an operating system especially when they are coming from the comfort of using Windows or macOS.

Here we present the basic but very important Ubuntu commands to give you an in-depth knowledge of how to use your Linux terminal.

Commands used for System Information

date

The simple “date” command displays the current date and time (including the day of the week, month, time, time zone, year).
Syntax: date
Example:

Linux date command

a. TZ

By default, “date” command uses the time zone defined in path “/etc/localtime”. Linux user can change the time zone via Terminal by using command “TZ”.
Syntax: TZ=Name_of_Time_Zone date
Example:

Set Timezone for date command

b. Use –set to set date and Time on Linux

Linux allows its user to set the current date and time of the system manually.
Syntax: date –set=”Date_in_format(YYMMDD) Time_in_format(HH:MM)”
Example:

sudo date --set="20230519 22:10"

Set date and time on Linux

c. -d

To operate the system on a specific date, you can change the date by using “-d”.
Syntax: date -d Date_to_operate_system_on
Example:

date -d now date -d yesterday date -d tomorrow date -d last-Sunday date -d "1997-04-22"

Calculate dates

df

The command “df” shows the amount of disk space used and disk space available on every file system containing each filesystem’s name and its path.
Syntax: df
Example:

Ubuntu df command

a. df -h displays the output in human-readable format

The command “df -h” shows the same result as the command “df” but now the data is in a more human-readable form that can be easily comprehended by a new user.
Syntax: df -h
Example:

DF command result in human readable format

free

The command “free” displays the amount of free and used memory in the complete system.
Syntax: free
Example:

Show free memory in Ubuntu

ps

The command “ps” which is also known as the process status command is used to provide information about the processes currently running on the system, including their respective process identification numbers (PIDs).
Syntax: ps
Example:

Use ps command in Ubuntu

The ps command is commonly used with these parameters to show the process list:

Читайте также:  Заполнение pdf форм linux

ps aux command on Ubuntu

uptime

The command “uptime” provides information about how long the system has been running in one line. The result for this command includes the current time, the time duration system has been running, the number of users who are currently logged on, and the system load averages for the past 1, 5, and 15 minutes respectively.
Syntax: uptime
Example:

Ubuntu Uptime Command

w

The command “w” displays detailed information about the users who are logged into the system currently.
Syntax: w
Example:

Ubuntu w command

passwd

The command “passwd” stands for password and it is used to change the password of the user.
Syntax: passwd user_name
Example:

Ubuntu passwd command

exit

Ubuntu Exit command

The command “exit” as the name says it is used to exit from the system and log out from the current user.
Syntax: exit
Example:

shutdown

Ubuntu shutdown command

The command “shutdown” is used to shut down the system.
Syntax: shutdown
Example:

Commands used for File Handling

mkdir

The command “mkdir” allows users to create directories/folders in the system. The user running this command must have suitable rights over the parent directory to create a directory or they will receive an error.
Syntax: mkdir New_Directory’s_Name
Example:

Entering the command “mkdir NewDirectory” will create the directory named as NewDirectory in the current directory.

Ubuntu mkdir command

rmdir

The command “rmdir” allows users to remove directories/folders from the system. The user running this command must have suitable rights over the parent directory to remove a directory or they will receive an error.
Syntax: rmdir Directory’s_Name
Example:

Entering the command “rmdir NewDirectory” will remove the directory named as NewDirectory in the current directory.

Ubuntu rmdir command

rm

The command “rm” is used to remove files from the directory.
Syntax: rm file’s_name
Example:

This above-mentioned command will remove the file “Test_File” from the Desktop directory.

Ubuntu rm command

mv

The command “mv” is used for two purposes

  • To move files or directories from one path to another path in the system.
  • To rename a file or folder.

a. “mv” to Move Files

Syntax: mv Source_File_name Destination_File_Name
Example:
Consider having two files in a directory (File1 and File2). Entering the command “mv File1 File2” will move data of File1 to File2 and delete source file(i.e. File1) from the system.

Ubuntu mv command

b. “mv” to Rename Files

Syntax: mv File_name New_name_for_file
Example:
Consider having two files in a directory (File1 and File2). Entering the command “mv File1 File_Rename” will rename File1 to File_Rename in the same directory.

mv command example

cp

The command “cp” is used to copy data from a source file to the destination file. Its function is almost like the command “mv”. The only difference is by using the command “cp” the source file is not removed from the directory after its data is moved to the destination file.
Syntax: cp source_file_name destination_file_name
Example:

Читайте также:  What is trace command in linux

Consider having two files (A and B) in Desktop Directory. Entering the command “cp A B” will copy all the data from file A to file B and user can still access both files (A and B).

Ubuntu cp command

cat

The command “cat” is a reverse of the command “tac”. It is used to display each line of the file starting from the first row and finishing on its last row.

This command is more frequently used than “tac”.
Syntax: cat file_name
Example:

Consider having a file named Test_File as shown below, “cat” command will display its data on the screen.

Ubuntu cat command

Consider having two files (File1 and File2) in the Desktop directory. Via the above-mentioned cat command, the User can display data from both the files on their screen.

Cat command example

cat File1 File2 >File_Output

Consider having two files (File1 and File2) in the Desktop directory. Via above-mentioned cat command the user can create a new file (File_Output) and append data from both the files (File1 and File2) into this new file named as File_Output by using operand “>”.

Another cat command example

The command “head” prints the top N rows of data of the given input or file. By default, it prints the first 10 lines of the specified files.
Syntax:

The above-mentioned command will only print first 5 rows of the file New_Test.txt

Ubuntu head command

tail

The command “tail” prints the last N rows of data of the given input or file. By default, it prints the last 10 lines of the specified files.
Syntax:

The above-mentioned command will only print last 5 rows of the file New_Test.txt.

Ubuntu tail command

echo

The command “echo” used to display any expression that is passed as an argument.
Syntax:
echo expression_to_be_displayed
Example:

This command displays the expression “user” on the screen.

Ubuntu echo command

grep

The command “grep” is used to search for a text in the specified file/folder.
Syntax: grep “expression_to_be_Searched” file_name_to_search_in
Example:

The above-mentioned command will search for the word “Are” in the text of the file B.

Ubuntu grep command

zip

The command “zip” is used to compress one or more files and store them in a new file with .zip extension.

Syntax: zip new_zip_file_name.zip
Example:

zip Files.zip Check.txt Test.txt Output.txt

The above-mentioned command will compress all three files (Check.txt, and Test.txt and Output.txt) and store these in a new file which we’re creating through this command i.e. Files.zip.

Ubuntu zip command

unzip

The command “unzip” is used to decompress a .zip file and extract all the files within to current directory.
Syntax: unzip zip_file_name.zip
Example:

Consider having a zip File named as Files.zip with a compressed .txt file in it. The above-mentioned command will help you unzip the file (Files.zip) and extract the .txt file from it to the current directory.

Ubuntu unzip command

sudo

Ubuntu sudo command

The command “sudo -I” is used to continue the session as a root user which has a lot more privileges than normal system user.
Syntax: sudo -i
Example:

Читайте также:  Лучший linux 32 bit

Basic Commands

history

The simple command “history” displays the list of all commands entered since the user started the session.
Syntax: history
Example:
Note: To clear all the previous history use command “history -c”.

Ubuntu history command

help

Ubuntu help command

The command of “help” provides you help to learn about all the built-in commands.
Syntax: help
Example:

man

The command of “man” stands for manual and it is used to display the user manual of any built-in Linux command.
Syntax: man command_name
Example:

This command displays the user manual of the built-in Linux command “vim”.

Ubuntu man command

dir

Ubuntu dir command

The command “dir” stands for directory and it is used to display the list of all directories or folder in the current directory.
Syntax: dir
Example:

ls

The command “ls” displays the list of all directories, folder, and files present in the current directory.
Syntax:

The above-mentioned command displays the name of directories, folders, and files

Ubuntu ls command

The above-mentioned command displays the name of directories, folders, files with their respective owner name, group’s name, and rights your user has over these.

ls command example

cd

The command “cd” stands for change directory and it is used to change the current directory user is operating in via Terminal.
Syntax:

  • cd destination_directory’s_name (to move forward from your current directory to the next directory within current directory)
  • cd .. (to move back in the previous directory from your current directory)

This command takes you from Directory /home/user to the destination directory which is /home/user/Desktop.

Note: You cannot only use cd when the destination directory is within your current directory.

Ubuntu cd command

This command takes you from directory /home/user/Desktop back to /home/user.

cd command example

pwd

Ubuntu pwd command

The command “pwd” displays the path of the current directory user is operating in via Terminal.
Syntax: pwd
Example:

clear

The command “clear” is to clear the screen of Terminal.
Syntax: clear
Example:

Ubuntu clear command

Clear command result

whereis

The command “whereis” is self-explanatory, as it displays the path where the package for specific built-in Linux command locates.

Syntax: whereis command_name
Example:

Ubuntu whereis command

whatis

The command “whatis” is also self-explanatory, as it displays a brief description of what is the functionality of specific built-in Linux command.
Syntax: whatis command_name
Example:

Ubuntu whatis command

With this, we wish you all the luck for your journey with Ubuntu! You will find the OS difficult initially, however with the commands and instructions given above, you will save a lot of time. A strong grip over the Linux Terminal is what makes the user dominant over the system.

About This Site

Vitux.com aims to become a Linux compendium with lots of unique and up to date tutorials.

Latest Tutorials

Источник

Оцените статью
Adblock
detector