Important LINUX Commands & related Info




Command that lists the last certain number of commands.
history

history -E     {all commands sort by date and time}

history [x]    {List of last x number of commands by using a number}

Command line shortcuts:

ShortcutDescription
CTRL + Rsearch for command that we entered on terminal
CTRL + Pshows the previously run command







Copy files and Directories:
cp [NAME OF FILE 1] [NAME OF FILE 2] {copy a file into another file}

cp [NAME OF FILE] [NAME OF DIRECTORY] {copy files into directories}

Move files and directories:
mv [NAME OF FILE 1] [NAME OF FILE 2]  {if the second file doesn’t exist, the first file is renamed as the second file}

mv [NAME OF DIRECTORY 1] [NAME OF DIRECTORY 2] {f the second directory does not exist then the first directory is simply renamed}

Command to select command from history
! <command number>

Remove file or directory:
rm [name of the file 1] [name of the file 2]

If special characters or spaces present in folder name or file name use quotes:
cd /path/to/folder/"My Documents"

Using grep with history to search command from history:
history | grep <command_to_be_search>

Using tail command to see latest changes in the given file{mainly log files}
tail -f  <file name>

EX: tail -f  /var/nyt/logs/sugarcrm/sugarcrm.log

Command to print last 25 lines in the given file:
tail -25 <file name>

Command to print first 25 lines in the given file:
head -25 <file name>

Create Directory:
mkdir /home/user/Documents/Apps {If there aren’t folders for the full path, running this command creates directories[home, user, Documents, Apps] for all of the folders in the path.}

How to use the calendar command:
calendar of current month : cal

calendar of current year: cal -y

calendar of the year 2015: cal 2015

calendar of February 1993: cal 2 1993

calendar of the previous,current and upcoming months: cal -3

How to clear the Terminal:
clear

How to close your Terminal:
exit

How to open file from command line in text editor:
open -a <editor name> <file path>

open -t <file name> {open file in default text editor}

How to access different directories in linux:
Description
Directory Symbol
The root directory
/
The home directory
~
The current directory
.
The parent directory
..
The previous directory
-

Navigation commands:
Command
Description
pwd
It stands for print working directory, It simply print the absolute path name of your current working directory
cd <directory_path>
It stands for change directory, and it simply change your current directory to given directory path.
cd /
Changes to your root directory
cd ~ 
Changes to your home directory
cd .. 
 Changes to your parent directory
cd .  
Doesn't do anything !
cd -
Changes to your previous directory
ls 
Stands for list, It simply lists all the files on your current working directory
ls /
This will list the files in your root directory.
ls ~
This will list the files in your home directory.
ls ..
This will list the files of your parent directory.
ls /home/user/Desktop
Here we are using the absolute pathname to list the files that are present on user's Desktop.  Put your username instead of user to see the files that are present on your desktop
ls ~/Desktop
Here we are using the relative pathname to list the files that are present on your Desktop.



How to execute multiple commands:
sudo apt-get update && sudo apt-get upgrade {second command won’t execute if first command fails}

sudo apt-get update ; sudo apt-get upgrade {second command will execute irrespective of first command}

Inode:
Every file on a Linux system has an inode which is also referred to as index node.
Typically an inode contains the following information about a file:
(1) Inode number
(2) File size
(3) File type
(4) Owner
(5) Permissions
(6) Number of Links

ls -i file1.txtview the inode number of file1.txt
ls -i show all the inode numbers in your current directory.

Re-Run Command:
!! {last executed command from history}
!<command number from history> {to execute particular command}
Viewing the file size:
COMING SOON....

                       

Popular

PASSWORD MANAGER–DashLane

USEFUL EXTENSIONS IN CHROME