Skip to main content

Posts

Showing posts with the label Linux

Essential Linux Commands for DevOps Engineers

Essential Linux Commands for DevOps Engineers Essential Linux Commands for DevOps Engineers In this article, we’ll explore some essential Linux commands that are frequently used by DevOps engineers in their daily workflows. Mastering these commands can significantly improve efficiency and streamline operations. System Information Commands hostname – Displays the system’s hostname. hostid – Shows the unique host ID assigned by the OS. date – Shows the current date and time in UTC format. whoami – Displays the current terminal’s logged-in username. uptime – Shows the duration since the system was last started. uname – Provides system information (Unix name). clear – Clears the terminal screen. history – Lists all previously executed commands. sudo – Super User Do (executes commands with superuser privileges). echo $? – Shows the exit status o...

grep command in Linux

In Linux grep stands for “global regular expression print”. The grep command used in searching and matching text files contained in the regular expressions. The syntax is: # grep pattern filename SNo Example Explanation 1 # grep apple filename The word apple will get extract from the filename 2 # grep -i apple filename ‘-i’  is a ignore case sensitive 3 # ls -l | grep filename List the files and in the listed files extract the filename 4 # ls -l | grep d Lists all the directories including files starting with d 5 # ls -l | grep ^d In this we will get only directories starting character of ‘d’ 6 # ls -l | grep ^- In this we will get only files

find command in Linux

The find command is used to find the files or directories path. The syntax is: # find /- [option] [filename] Option Usage -name For searching a file with its name -user For files whose owner is a particular user -group For files belonging to particular group  

Telnet in Linux

Connect to remote host / Check the port availability. Some of commands while using telnet: # netstat -tulpn   This commands shows which ports are used in this system  # telnet localhost 80   If this command throws an error like connection refused then the port 80 is not in use. We can use this port.  If this command throws an error like connected then the port is in use. We cannot use this port/li> Telnet is used to check whether a particular port is used or not. To exit from telnet command press ctrl + j Default Ports: Port Number Service 21 FTP ( File Transfer protocol ) 22 SSH ( Secure Shell) 23 Telnet 25 SMTP ( Simple Mail Transfer Protocol) 53 DNS (Domain Name Server ) 8...

Hostname in Linux

It lists the name of the server. We can change hostname of the server in 2 ways: 1) Permanent Change : Go to the file located in /etc/hostname (We have to edit the hostname in this file)    # vi /etc/hostname Provide the name whichever you want the hostname and save the file and exit from the file. After performing this please restart the system. The command to restart the system is    # init 6 2) Temporary Change    # hostname <name> Exit and login the server. It will rename your hostname

Networking commands in Linux

Command Description hostname List hostname of the server ping Availability of the destination server over the network Ex: ping www.google.com wget Download packages / Softwares into a Linux system   Ex: wget <linux_downloadable_url> ifconfig List’s IP address of the server Ex: ifconfig / ifconfig -a telnet Connect to remote host / Check the port availability Ex: telnet localhost 8081 curl Access the application Ex: curl www.google.com

Managing files or Directories in Linux

  Command Description cp Copy content from one file to another Syntax : cp <source> <destination>  To copy files # cp file1 file2   To copy directories Ex: cp -r dir1 dir2 Note : If file2 & dir2 doesn’t exist it will create mv mv stands for move. mv is used to move one or more files or directories from one place to another in a file system like UNIX. It has two distinct functions: è It renames a file or folder. è It moves a group of files to a different directory. find Find command is used to find the files or directories path. It is exactly like the find option in windows where you can search a file. Syntax: find / -name filename grep Search for a pattern in a file cd Swi...

Create and delete File/ Directory in Linux:

  Command Description touch Create a 0 bytes file cat > filename Create a file and allow to write (ctrl+c) to exit Override cat >> filename Add content to the existing file Appending vi Create a file if doesn’t exist and add the content in the vi editor rm Remove a file Ex: rm filename rm -f Remove a file forcefully Ex: rm -f filename mkdir Create a Directory rmdir Remove a empty directory rm -rf Remove a directory forcefully Ex: rm -rf dir ls -l Long Listing (In Alphabetic order) ls -lt ...

Commands for Reading a file in Linux

  Command Description ls Directory listing cat filename View file content less View file page by page Ex: less < filename> It will display a page. If we enter space we will get another page If we want to exit please click Q or q on your keyboard page Display file page by page (Ubuntu flavor) more Output the contents of the file Ex: more filename head Output the required number of lines from top to bottom in a file Ex: head -5 filename tail Output the required number of lines from bottom to top in a file Ex: tail -5 filename  

Some basic Linux commands

Command Description date Show the current date and time cal Show the month calendar # cal à Shows current month of the calendar # cal nav 1979 à Shows particular month & year of the calendar uptime Show current uptime (System up and running) whoami Who you are logged in as finger Display information about the user users/id Shows user information man Shows manual of a command Ex: man cat username Shows your username who/w Display who is online in a server

Linux File System Hierarchy

In Linux, the top level directory represented by “ / ”. It is also known as ROOT directory or Parent directory. ( The root account is like a system administrator account. It provides you full control of the system. You can create and maintain user accounts, assign different permission for each account, etc. )  The home directory for root user is “ /root ”. It is also known as Super user. It provides working environment for root user.  The home directory for all other users is “ /home ”. It provides working environment for all other users.  The default software’s are installed in “ /usr ” ( Unix Sharable Resources directory )  The commands used by all users are stored in “ /bin ” whereas the commands used by Super user stored in “ /sbin ” directory.  The variables data like mails, log files stored in “ /var ” directory The /tmp directory is a temporary landing place for files. All users can access this directory.

What is Linux?

Linux is an Open-Source Operating System based on Unix.  Linux was first introduced by Linus Torvalds.  The main purpose of Linux was to provide free and low-cost Operating System for users. Since Linux is cost-free, so it is conveniently downloadable and used by people.  Linux is open-source, so it is open to use, and developers may also try to improve the Linux operating system’s features.  It’s a multi-use operating system so multiple people may use the model.  Linux can operate on various types of hardware, so Linux is transportable.  Linux is secure, as it offers secure passwords and data encryption.