0% found this document useful (0 votes)
16 views

Linux essentials for DevOps

This document provides a comprehensive list of essential Linux commands for DevOps, detailing their functions and usage examples. Key commands include file management (ls, cp, mv, rm), directory navigation (cd, mkdir, rmdir), process management (ps, top, kill), and system information (df, free, uptime). Additionally, it includes shortcuts for terminal operations to enhance efficiency.

Uploaded by

rajuklp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Linux essentials for DevOps

This document provides a comprehensive list of essential Linux commands for DevOps, detailing their functions and usage examples. Key commands include file management (ls, cp, mv, rm), directory navigation (cd, mkdir, rmdir), process management (ps, top, kill), and system information (df, free, uptime). Additionally, it includes shortcuts for terminal operations to enhance efficiency.

Uploaded by

rajuklp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Some Essential Linux Commands For DevOps

1. ls: (List Segment) Lists all files and directories in the current directory.

2. ls -a: Shows hidden files (hidden files in linux are starting with a dot).

3. ls -l: Lists files and directories along with permissions, size, owner, group, date and time of last
modification.

4. cd <directory_name>: (Change Directory) Changes to the specified directory.

Ex: cd /home (home is a directory)

5. cd .. : Moves one level up to the parent directory (Suppose you are currently in the directory
/home/user/documents. If you run the command (cd ..)You will be moved up one level to /home/user, as
this is the parent directory of /home/user/documents. If you run cd .. again from /home/user, you will
move up another level, and the directory will change to /home, which is the parent of /home/user. If you
run cd .. when you're at the root directory /, nothing will happen because / is the top-level directory and
does not have a parent.)

6. pwd: (Print Working Directory) Displays the full path to the current directory.

7. mkdir <directoryname>: (Make Directory) Creates a new directory in the current working directory.

Ex: mkdir cloud

mkdir aa bb cc dd (make multiple directories at same time)

mkdir –p /a/b/c/d (make a nested directory )

8. cat <filename>: (Concatenate) Displays the content of a file or creates a new file.

Ex: cat > aws (to create file using cat command we use > followed by file nam)

cat aws ( to see content of file)

9. touch <filename>: Creates a new empty file.

Ex: touch test1

touch test1 test2 test3 test4 (to make multiple empty file at same time )

10. rm <filename>: (Remove) Deletes the specified file.

Ex: rm test1

11. rmdir <directoryname>: (Remove Directory) Deletes an empty directory.

Ex: rmdir xyz

12. cp <source> <destination>: (Copy) Copies a file or folder from the source to the destination.

Ex: cp file1 file2 (cp copies a file or directory)

13. mv <source> <destination>: (Move) Moves a file or folder from the source to the destination or
renames it.
Ex: mv file1 file2 (mv deletes the source file or directory after moving it.)

14. cp -r <source> <destination>: Copies directories recursively.

Ex: cp –r file1 file2 (-r stands for recursive)

15. find / -name <filename>: Searches for a file or directory by its name, starting from the root directory.

Ex: find / -name project (here project is file or folder name)

16. less <filename>: Views the content of a file page by page (great for large files).

Ex: less project

17. head <filename>: Displays the first ten lines of a file.

Ex: head /etc/passwd (to see any number of line use –n <number of line> for example to see
only 2 lines from top command will be: head –n 2 file name)

18. tail <filename>: Displays the last ten lines of a file.

Ex: tail /etc/passwd

19. ps: Displays currently active processes.

20. top: (Table of processes) Displays all running processes in real-time.

21. kill <pid>: (Process ID) Kills the process with the given PID (Process ID).

22. pkill <name>: Kills the process by name.

23. chmod <octal> <filename>: (Change Mode) Changes the permissions of a file (Octal values between 0
and 7).

Ex: Chmod 755 test1 (755 is permission for file test1)

24. chown <ownername> <filename>: (Change Owner) Changes the owner of a file.

Ex: chown prity test1 (prity user will become owner of file test1)

25. chgrp <groupname> <filename>: (Change Group) Changes the group owner of a file.

Ex: chgrp HR test1 (here HR is name of group)

26. grep <pattern> <files>: (Global Regular Expression Print) Searches for a pattern in files.

Ex: grep root /etc/passwd (root is pattern we want to search)

27. grep -r <pattern> <dir>: Searches recursively for a pattern in a directory.

Ex: grep –r root /etc/passwd (root is pattern we want to search)

28. echo 'text': Prints text to the console.

Ex: echo “Welcome”

29. diff <file1> <file2> : (Difference) Compares two files and shows the differences.

30. wc <filename>: (Word Count) Counts lines, words, and characters in a file.
Ex: wc test1

31. df: (Disk Filesystem) Shows disk usage for file systems.

32. df -h: Shows disk usage in a human-readable format.

33. du –sh <file/folder>: (Disk Usage) See the size of file and folder.

Ex: du –sh /etc/passwd

34. free: Displays memory and swap usage.

35. date: Displays the current date and time.

36. cal: (calendar ) Displays this month’s calendar.

37. uptime: Shows system uptime.

38. whoami: See the logging user name

39. hostname: See the host name.

40. history: Display all used commands


41. man: (Manual) Displays the user manual for other commands, helping us understand how to use them
and what options they support.
Ex: man ls , man mkdir
42. ls –i: Show file and folders with name and inode number.

Shortcuts :
Command Description

ctrl+c Terminates a process.

ctrl+z Stop a process and puts it in the background.

ctrl+d Logs out from the current session.

ctrl+l Clears the terminal screen.

tab Auto- completes flie/ directory names

You might also like