DMCA.com Protection Status Trending Topics About Devops: June 2025

Monday, 16 June 2025

50+ essential Linux commands(cheatsheet)

 Absolutely! As a DevOps professional, it’s vital to be proficient in the Linux command line for effective server management, automation, and troubleshooting. In this comprehensive guide, we’ll cover 50+ essential Linux commands(cheatsheet) with clear explanations and practical examples. This will help you enhance your Linux skills in a straightforward and practical manner.

  1. id - This is used to find out user and group names and numeric ID’s (UID or group ID) of the current user or any other user in the server.
    Example: id -u root

2. cd - Change Directory: Navigate to a different directory.
Example:cd /home/user/documents

3. pwd - Print Working Directory: Display the current directory's full path. Example: pwd

4. mkdir - Make Directory: Create a new directory.
Example: mkdir new_folder

5. rm - Remove: Delete files or directories.
Example: rm file.txt

6. cp - Copy: Copy files or directories.
Example: cp file.txt /backup

7. mv - Move: Move files or directories.
Example: mv file.txt /new_location

8. touch - Create Empty File: Create a new empty file.
Example: touch new_file.txt

9. cat - Concatenate and Display: View the content of a file.
Example: cat file.txt

10. nano - Text Editor: Open a text file for editing.
Example: nano file.txt

11. grep - Search Text: Search for text patterns in files.
Example: grep "pattern" file.txt

12. find - Search Files and Directories: Search for files and directories. Example: find /path/to/search -name "file_name"

13. chmod - Change File Permissions: Modify file permissions.
Example: chmod 755 file.sh

14. chown - Change Ownership: Change the owner and group of a file or directory.
Example: chown user:group file.txt

15. ps - Process Status: Display running processes.
Example: ps aux

16. top - Monitor System Activity: Monitor system processes in real-time. Example: top

17. kill - Terminate Processes: Terminate a process using its ID. Also can use pkill to terminate processes based on their name or other attributes.
Example: kill PID
pkill Process_Name

18. wget - Download Files: Download files from the internet.
Example: wget https://example.com/file.zip

19. less - To view the contents of a file one screen at a time, allowing for easy navigation and search within the file. Example: less test.log

20. tar - Archive and Extract: Create or extract compressed archive files. Example: tar -czvf archive.tar.gz folder

21. ssh - Secure Shell: Connect to a remote server securely.
Example: ssh user@remote_host

22. scp - Securely Copy Files: Copy files between local and remote systems using SSH.
Example: scp file.txt user@remote_host:/path

23. rsync - Remote Sync: Synchronize files and directories between systems.
Example: rsync -avz local_folder/ user@remote_host:remote_folder/

24. df - Disk Free Space: Display disk space usage.
Example: df -h

25. du - Disk Usage: Show the size of files and directories.
Example: du -sh /path/to/directory

26. ifconfig - Network Configuration: Display or configure network interfaces (deprecated, use ip).
Example: ifconfig

27. ip - IP Configuration: Manage IP addresses and network settings. Example: ip addr show

28. netstat - Network Statistics: Display network connections and statistics (deprecated, use ss).
Example: netstat -tuln

29. systemctl - System Control: Manage system services using systemd. Example: systemctl start service_name

30. journalctl - Systemd Journal: View system logs using systemd's journal.
Example: journalctl -u service_name

31. free - This command displays the total amount of free space available.
Example: free -m

32. at - Execute Commands Later: Run commands at a specified time. Example: echo "command" | at 15:30

33. ping - Network Connectivity: Check network connectivity to a host. Example: ping google.com

34. traceroute - Trace Route: Trace the route packets take to reach a host. Example: traceroute google.com

35. - Check Website Connectivity: Check if a website is up.
Example: curl -Is https://example.com | head -n 1

36. dig - Domain Information Groper: Retrieve DNS information for a domain.
Example: dig example.com

37. hostname - Display or Set Hostname: Display or change the system's hostname.
Example: hostname

38. who - Display Users: Display currently logged-in users.
Example: who

39. useradd - Add User: Create a new user account.
Example: useradd newuser

40. usermod - Modify User: Modify user account properties.
Example: usermod -aG groupname username

41. passwd - Change Password: Change user password.
Example: passwd username

42. sudo - Superuser Do: Execute commands as the superuser.
Example: sudo command

43. lsof - List Open Files: List open files and processes using them. Example: lsof -i :port

44. nc - Netcat: Networking utility to read and write data across network connections.
Example: echo "Hello" | nc host port

45. scp - Secure Copy Between Hosts: Copy files securely between hosts. Example: scp file.txt user@remote_host:/path

46. sed - Stream Editor: Text manipulation using regex.
Example: sed 's/old/new/g' file.txt

47. awk - Text Processing: Pattern scanning and text processing.
Example: awk '{print $2}' file.txt

48. cut - Text Column Extraction: Extract specific columns from text. Example: cut -d"," -f2 file.csv

49. sort - Sort Lines: Sort lines of text files.
Example: sort file.txt

50. diff - File Comparison: Compare two files and show differences. Example: diff file1.txt file2.txt

51. ls - List Files and Directories: List the contents of a directory.
Example: ls -la

52. history - This command is used to view the previously executed command.
Example: history 10

53. cron - Schedule Tasks: Manage scheduled tasks.
Example: crontab -e

54. ssh-keygen - This command is used to generate a public/private authentication key pair. This process of authentication allows the user to connect remote server without providing a password.
Example: ssh-keygen

55. nslookup - This stands for “Name server Lookup”. This is a tool for checking DNS hostname to Ip or Ip to Hostname. This is very helpful while troubleshooting.
Example: nslookup google.com

56. tr - For translating or deleting characters.

These commands cover a wide range of tasks that are essential for DevOps professionals working with Linux systems. Remember to always refer to the man pages (man command) for more detailed information about each command and its options.
Example:cat crazy.txt | tr "[a-z]" "[A-Z]"

57. tnc - This is “Test Network Connection” command. Mostly used command while troubleshooting. It displays diagnostic information for a connection.
Example:tnc google.com --port 443

58. w - Displays current user.

59. su - Switch User.
Example: su - root

60. ac(All Connections) — Total connect time for all users or specified users.
Example: ac john

61. tail — Displays the last part of a file, commonly used to monitor logs in real-time.
Example: tail monitor.logs

62. head — Displays the first part of a file, often used to quickly see the beginning of a file’s content.
Example: head content.txt

63. ip route — To show or manipulate the IP routing table. Shows clear ip tables rules.
Example: ip rout

Linux Commands and tricks for DevOps tasks read more

Conclusion

DevOps professionals often rely on a set of essential Linux commands to manage systems, automate tasks, and ensure the smooth operation of infrastructure. These commands are foundational for DevOps tasks and are used in various contexts, from system administration to deployment automation.

Thursday, 5 June 2025

GIT

Git is a distributed version control system that allows multiple developers to collaborate on a project, tracking changes to files and managing different versions of the codebase. Here's a brief explanation of how Git works:

Repositories

A Git repository is a directory or folder that contains your project's files, as well as the entire history of changes made to those files. It acts as a central hub for collaboration.

Commits

In Git, a commit represents a snapshot of your project at a specific point in time. Each commit is associated with a unique identifier (a hash) and contains information such as the author, timestamp, and a message describing the changes made in that commit.

Branches

Git allows you to create branches, which are independent lines of development. Each branch can have its own commits, allowing multiple developers to work on different features or bug fixes simultaneously. Branches make it easy to experiment, collaborate, and merge changes back into the main codebase.

Working Directory, Staging Area, and Repository

Git has three main areas:

  1. Working Directory: This is the directory on your local machine where you modify and create files.

  2. Staging Area (Index): The staging area is an intermediate area where you select and stage the changes you want to include in the next commit. You can think of it as a holding area for changes you want to commit.

  3. Repository: The repository is where Git stores the complete history of your project, including all the committed changes. It is usually located in the hidden .git folder within your project directory.

Basic Workflow

The typical Git workflow involves the following steps:

  1. Initialize a repository: Use git init to create a new Git repository in your project directory, or git clone to clone an existing repository.

  2. Add and commit changes: Use git add to stage changes from your working directory to the staging area. Then use git commit to create a new commit with the staged changes, along with a descriptive commit message.

  3. Create and switch branches: Use git branch to create a new branch, and git checkout to switch to a different branch.

  4. Merge branches: Use git merge to merge changes from one branch into another. This combines the commits from both branches into a single branch.

  5. Push and pull changes: Use git push to upload your local commits to a remote repository, and git pull to fetch and integrate remote changes into your local repository.

Here are some commonly used Git commands with examples

Initialize a Git repository

Command:

git init

Example:

$ git init
Initialized empty Git repository in /path/to/repository/.git/

Clone a repository

Command:

git clone <repository_url>

Example:

$ git clone https://github.com/username/repository.git
Cloning into 'repository'...
remote: Enumerating objects: 25, done.
remote: Counting objects: 100% (25/25), done.
remote: Compressing objects: 100% (18/18), done.
remote: Total 25 (delta 6), reused 22 (delta 5), pack-reused 0
Unpacking objects: 100% (25/25), done.

Stage changes

Command:

git add <file_name>

Example:

$ git add index.html

Commit changes

Command:

git commit -m "Commit message"

Example:

$ git commit -m "Add initial version of index.html"

Create a new branch

Command:

git branch <branch_name>

Example:

$ git branch feature/add-new-feature

Switch to a branch

Command:

git checkout <branch_name>

Example:

$ git checkout feature/add-new-feature

Push changes to a remote repository

Command:

git push <remote_name> <branch_name>

Example:

$ git push origin main

Pull changes from a remote repository

Command:

git pull <remote_name> <branch_name>

Example:

$ git pull origin main

Merge a branch into the current branch

Command:

git merge <branch_name>

Example:

$ git merge feature/add-new-feature

View commit history

Command:

git log

Example:

$ git log
commit a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6
Author: John Doe <john.doe@example.com>
Date:   Mon Jul 05 12:34:56 2023 +0300

    Add initial version of index.html

commit b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q
Author: Jane Smith <jane.smith@example.com>
Date:   Sun Jul 04 09:12:34 2023 +0300

    Update README.md