ID #1193

Linux Commands

: Basic Linux Commands :

Note: The commands are CASE sensitive.

-To check whether working in which login currently:
whoami

 

If the user logged in as root then it will display as below:

[root@localhost ~]#


-To check whether working in which present working directory:

pwd

 

-to find out whether the linux OS is 32 Bit or 64 Bit:

getconf LONG_BIT

 

-to check the system information, like the kernel version, architecture, processor:

uname -a

 

-to check the IP address. (Displays information of the network interface): 

ifconfig

 

To display the ip's of all the network interface:
ifconfig -a

 

-to Query / check all the Installed RPM Packages. This command will list down all the rpm pacakages already installed in the system.

rpm -qa

 

-to Query a Particular RPM Package (to check whether that RPM package is installed or not).

 

rpm -q <package name>

 

For example: To check whether eScan packages are installed or not then type the below command individually for the respective package:

 

rpm -q mwav

rpm -q mwadmin

rpm -q escan

 

-to Query a Particular RPM Package with detailed information (to check whether that RPM package is installed or not along with it's details).

 

rpm -qi <package name>

 

For example: To check whether eScan package is installed or not and to view its details, then type the below command individually for the respective package:

 

rpm -qi mwav

rpm -qi mwadmin

rpm -qi escan


-to Query / check all the Installed Debian Packages. This command will list down all the debian pacakages already installed in the system. 

dpkg

 

-to Query a Particular Debian Package (to check whether that Debian package is installed or not).

 

For example: To check whether eScan packages are installed or not then type the below command individually for the respective package:

 

dpkg -l mwadmin
dpkg -l mwav
dpkg -l escan

 

-To mount an ISO image:

mount -o loop

mount -o loop <iso file name> /mnt/<folder path to mount the iso>

 

-to unmount an ISO image:
umount

 

-to view all the mounted devices:
df -h

 

-to create a directory / folder
mkdir -p <path of the folder to be created and the name of the folder to be created>

 

-to login with other user

 

-to copy a file:

cp <source file path> <destination path>

 

For example to copy /home/a.txt to /root type below command:

cp /home/a.txt /root

 

-to view/list all files found in the current directory, first go to that directory
and then enter below command. You can use either the ls or the find command.

 

ls

(or)

find .

(The dot after "find" indicates the current directory.) 

 

  

-Deleting files & folders;

to delete a file, type:
rm <file path>


to delete a folder, type:
rmdir <folder path>

 

to delete a folder and its sub-folders and files, type:

rm -rf <folder path>

(where, r is Recursive and f is Force)

 

-to create a file:

vi <file path and name of the file to be created>

 

For example: 

vi /home/a.txt

 

-to open / edit a file:

vi <file path>

 

For example to modify /home/a.txt file type below command:

vi /home/a.txt

 

Then to start editing/modifying the file press Esc button, then to get into editing mode press "i" button or press Insert key on the keyboard. Once the required modification is done then to come out of the insert mode type the Esc button and then TO SAVE AND CLOSE the file enter the below command:

:wq


To close the file WITHOUT SAVING type the below command:

:q


-to see memory usage:

free -m


-to view only the content of a file. For modifying file use the VI command)

cat <file path>


For exmaple to view the content of escan's license file type the below command:
cat /opt/MicroWorld/etc/keys/microworld.keys

 

-to check hostname

hostname

 

-to set hostname
hostname <desired name to be set for the system>

 

For example, to set the computer name as "my computer", type the below command:

hostname My Computer

 

-to check what processes running in the memory (task manager)

top

 

-to come out of top and return to terminal prompt:

Press Ctrl + C button

 

-to kill eScan GUI windows:

killall -9 escangui

 

-to go back to previous folder
cd ..


-to go back to root folder
cd /


-to check whether particular package is installed or not:

rpm -qi <name of that package>

 

for example, to check escan rpm installed or not type:

rpm -qi escan

 

-to check all running services
service --status-all


-to check a specific service (for example to check openssh service):
service sshd status

 

-to start / stop / restart a service:

service <package name> start

service <package name> stop

service <package name> restart

 

For example, to restart samba service, type below command:

service samba restart

 

-to extract an archive ( .tar.gz) file:

tar (path of the archive file>

 

For Example, to extract the offline update archive file of eScan, perform the below steps:

The file has to be first saved in the root (i.e. / ) and to be extracted as per the below command:

 

So assuming that the archive file is saved in the root then execute below command:

For 32 bit OS:
tar -xzvf mwav_32bit_daily_updates.tar.gz


For 64 bit OS:
tar -xzvf mwav_64bit_daily_updates.tar.gz

 

-How to reset root user login password?

Open a terminal program (command line, X terminal, whatever you want.)
type the below command:

sudo su


If you have any other user login then it will display that username and will prompt you
to enter that user's password so just enter that password and press Enter.

 

Now type below command to reset the password of root:
passwd


On the next prompt add the new password for the root user and Confirm same password in next prompt.

 

 


Tags: -

Related entries:

You can comment this FAQ