Saturday, September 12, 2020

Linux Commands Tutorial

 Linux Commands Tutorial


Introduction:In this Blog i am going to explain  Linux Commands Tutorial  Linux is a Unix-Like operating system. All the Linux/Unix commands are run in the terminal provided by the Linux system. This terminal is just like the command prompt of Windows OS. Linux/Unix commands are case-sensitive. The terminal can be used to accomplish all Administrative tasks


Let us Start the Process Linux Commands Tutorial


1)logname: It shows current username


# logname


2)pwd: Present working directory which means current folder in linux


# pwd


3)date: it display system date and time


# date


4)clear: to clear the screen


 # clear


5)cal: current month calendar we can call month and year along with cal command  ex: cal 5 1982  which displays may month 1982


 # cal


6)uname:  it dispalys the present os name.


 # uname


7)uname -r:  displays kernal version

 

# uname -r


8)hostname: displays server name


 # hostname


9)hostname -i: display server ip address


# hostname -i


10)who: it shows list  of connect user in that server

 

# who


11)who am i:  current logged user info


# who am i 


12)su:  switch username from one user into another user   ex:su - username(oracle is the username)


 # su - oracle 


13)exit:  logout from current user logged in


 # exit


14)man command name: help of the given command


# man


WORKING WITH FILES:


1)cat:  which is use to create a new file or open to  view existing files


# cat chaitanya.txt


2)cat>>filename: appending data to these file


# cat >> chaitanya.txt


3)$touch filename: which  create an empty file with zero kb


# touch chaitanya.txt



FILE DELETION:


 1)rm: to delete the file


# rm chaitanya1.txt


 2)rm -rf: delete the files forcibly 


# rm - rf chaitanya2.txt


 3)rm -i: delete the file which asks the  user conformation 


 # rm - i chaitanya.txt


 4)rm file1 file2: deleting multiple files


# rm chaitanya1.txt  chaitanya2.txt



WORKING WITH DIRECTORIES:



1)mkdir: To create a new directory (Directory is  nothing  but a drive or folders like windows) in linux (here i am using  Linux Commands Tutorial chaitanya is the directory name)


 # mkdir chaitanya  


2)cd dirname: to change a directory (one directory to another directory)


# cd orabackup


3)cd .. : to moves from  current directory into previous directory


# cd ..


4)cd: to come out entire directory


#  cd 


5)cd /: it changes the root directory


# cd /



REMOVING DIRECTORIES:



1)rmdir: to removing directory it must be empty( here i am using Linux Commands Tutorial chaitanya is the directory in that chaitanya directory it should be empty then only it will be deleted)


# rmdir chaitanya


2)rm -r direcname: it deletes recursively to entire structure


# rm - r chaitanya


3)rm -ri direcname: it deletes recursively to entire structure it will ask the user confirmation (here iam using  Linux Commands Tutorial chaitanya is the directory)

 

 # rm - ri


4)rm -rf direcname: it deletes recursively to entire structure with forcibly


# rm -rf


COPY COMMANDS


1)cp sourcefile targetfile: copying file from existing location into  new location


# cp chaitanya1.txt   chaitanya3.txt


# cp chaitanya3.doc  chaitanya03new.doc


# ls - l * .doc( it will displays all doc related files)


# ls - l *.txt (it will displays all text related files)


COPY MULTIPLE FILES SIMULTANEUOSLY INTO ANOTHER DIRECTORY


# cp main.txt demo.txt libc.txt     backup


If backup is located in /home/project, enter:


#  cp main.txt demo.txt libc.txt     /home/project backup


COPY A FILE TO ANOTHER DIRECTORY  


To copy a file from your current directory into another directory called /tmp/, 



# cp filename /tmp

# ls /tmp/filename

# cd /tmp

# ls


COPYING ALL FILES


The star wildcard represents anything i.e. all files. To copy all the files in a directory to a new directory, enter:


# cp *  /u01/oracle/backup


The star wildcard represents anything whose name ends with the .doc extension. So, to copy all the document files (*.doc) in a directory to a new directory, enter:


# cp *.doc  /u01/oracle/backup


To copy a directory, including all its files and subdirectories, to another directory, enter (copy directories recursively):


# cp -R *  /u01/oracle/backup


To copy a file to a new file and preserve the modification date, time, and access control list associated with the source file, enter:


# cp -p chaitanya.txt  /dir1/dir2/

$ cp -p filename /path/to/new/location/myfile


MOVING COMMANDS


1)mv old file newlocation: using these command we can move a file from one folder into  another  folder or we can rename file also


Move mainc.txt defh.txt  files to /u01/oracle/oracbackup/ directory:


# mv mainc.txt defh.txt   /u01/oracle/orabackup/


Move all C files in current directory to subdirectory orabackup :


# mv *.c orabackup



Move all files in subdirectory orabackup to current directory :


# mv orabackup/* .



Rename file main.c to main.backup:


# mv main.c main.backup



Rename directory bak to bak3:


# mv bak bak3


 

Update - move when main.c is newer:


# mv -u main.c bak

#



Move main.c and prompt before overwrite bak/main.c:


# mv -v main.c bak

'bak/main.c' -> 'bak/main.c'

#



VIEWING FILE COMMANDS


1)ls : it's listing files which are in that directory with  ascending order


# ls


2)ls -a: listed all files including  hidden files also


# ls -a 


3)ls -l: listed all files in long list  format i.e 9 field


# ls -1


4)ls -t: listed all files based on date and time of creation


# ls -t


5)ls -r: listed all files on descending order or sin reverse


# ls -r


6)ls -R: listed all files recursively


# ls -R


CREATING HIDDEN FILES


1)cat>.filename


# cat > .chaitanya9.txt


2)mv filename .filename


# mv chaitanya1.txt  .chaitanya6.txt


3)mkdir .dirname


# mkdir  .chaitanya


UNHIDE FILES


1)mv .chaitanya chaitanya


# mv  .chaitanya chaitanya


2)mv .dirname dirname


# mv . chaitanya chaitanya




Note: Info on  Linux Commands Tutorial it may be differ in your environment like production,testing development and naming conventions etc



THANKS FOR VIEWING MY BLOG FOR MORE UPDATES FOLLOW ME OR SUBSCRIBE ME

ITIL Process

ITIL Process Introduction In this Blog i am going to explain  ITIL Process, ITIL stands for Information Technology Infrastructure Library ...