Linux Basic Command

 The Basic and very useful Linux Commands

if we are talking about Linux os, it is safest and very light in use. It does not require a high configuration laptop Desktop. It can be used on older or newer Pc and installation is a little bit tougher than windows but it will configure your system according to the Linux environment. So using it having a different experience and looks like Programmer. So Let's see some basic and very useful commands of Linux.

pwd command:-

with the help of this command, you can locate your current working directory. The command will return your full path which is started with the slash (/).

cd command:-

with the help of this command, we can navigate through Linux Files and Directories. It requires Full Path or Directories Name

There are some shortcuts to use this command like 
  • cd .. (with two dots) to move one directory up
  • cd to go straight to the home folder
  • cd- (with a hyphen) to move your previous Directory

ls command:- 

you can relate this command as a list means to view the contents of the directory, type ls and then pathe of the directory.
There are some variations which can be used with ls is as follows:-
  • ls-R will list all the files in the sub-directories.
  • ls-a will show the hidden files.
  • ls -al  will list all files and directories with detailed information like permissions, size, owner, etc.

cat command:-

The cat command is one of the most used commands in Linux. It is used to list the contents of a file on the standard output (sdout). To run this command type cat Filename. For Example- cat file.txt

There are some other ways to use it like :-
  • cat > filename creates a new file.
  • cat filename1 filename2>filename3 join two files( filemane1 and filname2) and stores the output in filename3
  • to convert a file to upper or lower case use, cat filename | tr a-z A-Z>output.txt

cp command:-

this command is used to copy the file and paste it somewhere. For example, the command cp test.txt /home/username/Documents would create a copy of the file in Documents Directory.

mv command:-

this command is used to move a file from one directory to other directory although it can be used to rename the Directory name also.

this command is similar to the cp command. You need to type mv test.txt /home/username/Documents. it would move the test file into the Documents Directory.
To rename the directory name, you have to type mv test.txt test2.txt

mkdir command:-

this command is used to create a new Directory. For Example- mkdir Music , it would creat a new Directory Music.


rmdir command:-

this command is just opposite to the mkdir command. this command removes the directory however it allows only to delete empty directories.

rm command:-

this command is used to delete the Directory and content within them.

touch command:-

this command allows creating a new blank file through the Linux command line. for example-
touch /home/username/Desktop/webtest.html

locate command:-

this command is used to locate a file, it is similar to a search file in Windows. using the -i argument with the command will make it case-insensitive, so you can search for a file even if you don't remember its exact name.


find command:-

it is similar to locate command, using find also searches for file and directories. The difference between them is that find works with the given directories.


grep command:-

this command allows searching all the text in the given filename. for example- grep blue test.txt will search the word blue in the test.txt file.

sudo command:-

this is the most powerful command in Linux this command means SuperUser Do this command allows to perform tasks that require administrative or root permissions.

df command:-

Use the df command to get a report on the system disk space usage, expressed in percentage and KB. If you want to view the report in megabytes, type df -m.

du command:-

If you want to check how much space a file or directory takes up, the answer is the du (disk usage) command. However, the disk usage summary will show the disk block number instead of the usual size format. If you want to view it in bytes, kilobytes, and megabytes, add the -h parameter to the command line.


head command:-

The head command is used to view the first line of any text file. By default, it will display the first ten rows, but you can change this number to your liking. For example, if you only want to display the first five lines, type head -n 5 filename.txt.


tail command:-

The function of this command is similar to the head command, but the tail command will display the last ten lines of the text file instead of the first line. For example, tail -n filename.ext.

diff command:-

The diff command is short for difference. The diff command compares the contents of two files line by line. After analyzing the file, it will output unmatched lines. Programmers often use this command when they need to change the program instead of rewriting the entire source code.

The simplest form of this command is diff file1.ext file2.ext

tar command:-

The tar command is the most common command used to archive multiple files into a tarball-zip file is a common Linux file format, similar to the zip format, compression is optional.


chmod command:-

chmod is another Linux command used to change the read, write and execute permissions of files and directories. Since this command is quite complicated, you can read the complete tutorial to execute it correctly.

chown command:-

In Linux, all files are owned by a specific user. The chown command allows you to change or transfer the ownership of a file to a specified user name. For example, chown linuxuser2 file.ext will make linuxuser2 the owner of file.ext.


jobs command:-

The jobs command will display all current jobs and their status. Jobs are basically processes started by Shell.


Kill command:-

If your program is unresponsive, you can use the kill command to manually terminate it. It will send a specific signal to the malfunctioning application and instruct the application to terminate itself.

You can use 64 signals in total, but people usually only use two signals:

  • SIGTERM (15)-Request the program to stop running and give it some time to save all its progress. If you do not specify a signal when you enter the kill command, this signal will be used.
  • SIGKILL (9)-Force the program to stop immediately. Unsaved progress will be lost.
In addition to knowing the signal, you also need to know the process identification number (PID) of the program you want to kill. If you don't know the PID, just run the command ps ux.

After knowing what signal you want to use and the PID of the program, enter the following syntax:

Kill [signal options] PID.

ping command:-

Use the ping command to check the connection status with the server. For example, just type ping google.com and the command will check if you can connect to Google and measure the response time.

wget command:-

The Linux command line is very useful-you can even download files from the Internet with the help of the wget command. To do this, just type wget and then type the download link.


uname command:-

The uname command (short for Unix name) will display detailed information about the Linux system, such as computer name, operating system, kernel, etc.

top command:-

As a terminal equivalent to the task manager in Windows, the top command will display a list of running processes and how much CPU each process uses. Monitoring system resource usage is very useful, especially when knowing which process needs to be terminated because it consumes too many resources.

history command:-

After using Linux for a certain period of time, you will quickly notice that you can run hundreds of commands every day. Therefore, if you want to view the previously entered commands, the running history command is particularly useful.

Man command:-

Confused about the function of certain Linux commands? Don't worry, you can use the man command to easily learn how to use them from the Linux shell. For example, typing man tail will display the manual instructions for the tail command.


Echo command:-

This command is used to move some data to a file. For example, if you want to add the text "Hello, my name is John" to a file named name.txt, you can type echo Hello, and my name is John >> name.txt

zip, unzip command:-

Use the zip command to compress the files into a zip archive, and then use the unzip command to extract the compressed files from the zip archive.

Hostname command:-

If you want to know the name of the host/network, just type the host name. Adding -I at the end will show the IP address of the network.


useradd, userdel commands:-

Since Linux is a multi-user system, this means that multiple people can interact with the same system at the same time. useradd is used to create a new user, and passwd adds the password to the user's account. To add a new user named John, add user John, and then add its password type passwd 123456789.

Deleting a user is very similar to adding a new user. To delete a user account type, use userdel UserName















Comments

Popular posts from this blog

Programmingshark index 6

Proassignmenthelp index 12

Proassignmenthelp index 27