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

LINUX

linux ppt

Uploaded by

keveti1813
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

LINUX

linux ppt

Uploaded by

keveti1813
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

PREPARE HELP GUIDE USING SHELL SCRIPT FOR ALL THE MAJOR

LINUX COMMANDS

LINUX: -

Linux is an open-source operating system (OS). An operating system is the


software that directly manages a system's hardware and resources, like CPU,
memory, and storage. The OS sits between applications and hardware and
makes the connections between all your software and the physical resources
that do the work.

ADVANTAGES OF LINUX: -

Open source: Linux OS is an open-source operating system that can be


accessed and modified by anyone. This allows developers and users to
customize the operating system according to their needs.

Free: Linux is available for free and there is no need to pay licensing fees as
with Windows OS.

Stability: Linux OS is known for its stability as it has the ability to run
uninterrupted for weeks or even months without requiring a reboot.

Security: Linux OS is known to be secure and resistant to virus and malware


attacks. This is because Linux has tighter security settings compared to
Windows OS.

DISADVANTAGES OF LINUX: -

Lack of application support: Some applications that are commonly used in


Windows OS may not be available in Linux OS. Although many alternative
applications are available, some applications may not have the same features.
Lack of driver support: Linux sometimes has problems with supporting certain
hardware drivers. Although Linux driver support is constantly improving, there
are still some hardware devices that are not supported by Linux.

Not user-friendly: The interface or user interface of Linux is not as intuitive as


in Windows OS. This can be a challenge for users who are not familiar with
Linux.

SHELL SCRIPT: -

A shell script is a text file that contains a sequence of commands for a UNIX-
based operating system. It is called a shell script because it combines a
sequence of commands, that would otherwise have to be typed into the
keyboard one at a time, into a single script. The shell is the operating system's
command-line interface (CLI) and interpreter for the set of commands that are
used to communicate with the system.

A shell script is usually created for command sequences in which a user has a
need to use repeatedly to save time. Like other programs, the shell script can
contain parameters, comments and subcommands that the shell must follow.
Users initiate the sequence of commands in the shell script by simply entering
the file name on a command line.

ADVANTAGES OF SHELL SCRIPT: -

1. The commands and syntax of the shell script are the same as that entered at
the command line. Because of this, there is no need to switch to a completely
different syntax.
2. It is much faster to write a code in shell script than in other programming
languages. This also means that the program is easier to create, and files
required can be selected easily.

3. Shell script can also be used to provide linkage for already existing programs.

4. Shell scripting can be used by users that are not experts to modify and tailor
the behaviour of their programs according to their requirements.

DISADVANTAGES OF SHELL SCRIPT: -

1. There may be errors in shell scripting that prove to be quite costly.

2. The programs in shell script are quite slow while executing and a new
process is required for every shell command executed.

3. Different platforms in shell scripting may also have compatibility problems.


1)Displaying the file contents on the terminal: -

1.cat: - If you want to create a new file or overwrite an existing file with new
content, you can use ‘cat’ with the output redirection (`>`):

Syntax: - cat > newfile_name

Example: -

2.head: - Used to print the first N lines of a file. It accepts N as input and the
default value of N is 10.

Syntax: - head [OPTION]... [FILE]...

Example: -

3.Tail: - Used to print the last N-1 lines of a file. It accepts N as input and the
default value of N is 10.

Syntax: - tail [OPTION]... [FILE]...


Example: -

2)File and Directory Manipulation Commands: -

1.cp: -This command will copy the files and directories from the source path to
the destination path. It can copy a file/directory with the new name to the
destination path. It accepts the source file/directory and destination
file/directory.

Syntax: - cp source_file destination

Example: -

2.mv: - Used to move the files or directories. This command’s


working is almost similar to cp command, but it deletes a copy of the
file or directory from the source path.

Syntax: - mv [options(s)] [source_file_name(s)] [Destination_file_name]

Example: -
3.rm: - Used to remove files or directories.

Syntax: - rm [OPTION]... FILE...

Example: -

4.touch: - Used to create or update a file.

Syntax: - touch [options] file_name

Example: -

5.mkdir: - Used to create a directory if not already exist. It accepts the


directory name as an input parameter.

Syntax: - mkdir [options...] [directory_name]

3)Extract, sort, and filter data Commands: -

1.grep: - This command is used to search for the specified text in a file.
Syntax: - grep [options] pattern [files]

Example: -

2.sort: - This command is used to sort the contents of files.

Syntax: - sort file.txt

Example: -

3.wc: - Used to count the number of characters, words in a file.

Syntax: - wc [OPTION]... [FILE]...

Example: -
4.cut: - Used to cut a specified part of a file.

Syntax: - cut OPTION... [FILE]...

Example: -

4)File Permissions Commands: -

1.chown: - Used to change the owner of the file.

Syntax: - chown [options] new_owner[:new_group] file(s)

Example: -

2.chgrp : - Used to change the group owner of the file.

Syntax: - chgrp [OPTION]… GROUP FILE…

chgrp [OPTION]… –reference=RFILE FILE…

Example: -
3.chmod: - Used to modify the access/permission of a user.

Syntax: - chmod [options] [mode] [File_name]

Example: -
MAIN CADE WITH COMMANDS

show_help() {

echo "Linux Command Help Guide"

echo "1. pwd: Print the current working directory."

echo " Usage: pwd"

echo "2. ls: List directory contents."

echo " Usage: ls [options] [path]"

echo " Options: -l (long format), -a (show hidden files)"

echo "3. cd: Change the current directory."

echo " Usage: cd [directory]"

echo "4. cp: Copy files and directories."

echo " Usage: cp [options] source destination"

echo " Options: -r (recursive), -i (interactive)"

echo "5. mv: Move or rename files and directories."

echo " Usage: mv [options] source destination"

echo " Options: -i (interactive)"


echo "6. rm: Remove files or directories."

echo " Usage: rm [options] file"

echo " Options: -r (recursive), -i (interactive)"

echo "7. touch: Create an empty file or update the timestamp."

echo " Usage: touch filename"

echo "8. cat: Concatenate and display file contents."

echo " Usage: cat [options] file"

echo "9. echo: Display a line of text."

echo " Usage: echo [string]"

echo "10. man: Display the manual for a command."

echo " Usage: man command"

echo "11. chmod: Change file permissions."

echo " Usage: chmod [options] mode file"

echo " Options: + (add), - (remove), = (set)"


echo "12. chown: Change file owner and group."

echo " Usage: chown [options] owner:group file"

echo "13. ps: Report a snapshot of current processes."

echo " Usage: ps [options]"

echo " Options: aux (show all processes)"

echo "14. top: Display dynamic real-time information about running


processes."

echo " Usage: top"

echo "15. kill: Send a signal to a process."

echo " Usage: kill [options] pid"

echo "16. grep: Search for patterns in files."

echo " Usage: grep [options] pattern file"

echo "17. find: Search for files in a directory hierarchy."

echo " Usage: find [path] [options]"


echo "18. df: Report file system disk space usage."

echo " Usage: df [options]"

echo " Options: -h (human-readable)"

echo "19. du: Estimate file space usage."

echo " Usage: du [options] [path]"

echo " Options: -h (human-readable), -s (summary)"

echo "20. free: Display memory usage."

echo " Usage: free [options]"

echo " Options: -h (human-readable)"

echo "21. ifconfig: Configure a network interface."

echo " Usage: ifconfig [interface] [options]"

echo "22. ip: Show/manipulate routing, devices, policy routing, and


tunnels."

echo " Usage: ip [options] [object] [command]"

echo "23. wget: Download files from the web."


echo " Usage: wget [options] [URL]"

echo "24. curl: Transfer data from or to a server."

echo " Usage: curl [options] [URL]"

echo "25. tar: Archive files."

echo " Usage: tar [options] [file]"

echo " Options: -cvf (create), -xvf (extract)"

echo "26. zip: Package and compress files."

echo " Usage: zip [options] zipfile files"

echo "27. unzip: Extract compressed files."

echo " Usage: unzip [options] zipfile"

echo "28. history: Show command history."

echo " Usage: history"

echo "29. alias: Create shortcuts for commands."

echo " Usage: alias name='command'"


echo "30. unalias: Remove shortcuts for commands."

echo " Usage: unalias name"

echo "31. echo: Display a line of text or variable value."

echo " Usage: echo [string]"

echo "32. clear: Clear the terminal screen."

echo " Usage: clear"

echo "33. nano: Simple text editor."

echo " Usage: nano [file]"

echo "34. vi: Advanced text editor."

echo " Usage: vi [file]"

echo "35. ssh: Secure Shell for remote login."

echo " Usage: ssh [user@]hostname"

echo "36. scp: Securely copy files between hosts."

echo " Usage: scp [options] source destination"


echo "37. rsync: Sync files/directories between locations."

echo " Usage: rsync [options] source destination"

echo "38. df: Display free disk space."

echo " Usage: df [options]"

echo "39. du: Display disk usage of files."

echo " Usage: du [options] [path]"

echo "40. uname: Print system information."

echo " Usage: uname [options]"

echo "41. hostname: Show or set the system's host name."

echo " Usage: hostname [new_hostname]"

echo "42. reboot: Restart the system."

echo " Usage: reboot"

echo "43. shutdown: Turn off the system."

echo " Usage: shutdown [options] [time]"


echo "44. service: Start/stop/restart a service."

echo " Usage: service service_name [start|stop|restart|status]"

echo "45. systemctl: Control the systemd system and service manager."

echo " Usage: systemctl [options] command"

echo "46. journalctl: Query the systemd journal."

echo " Usage: journalctl [options]"

echo "47. crontab: Schedule jobs to run periodically."

echo " Usage: crontab [options] [file]"

echo "48. passwd: Change a user's password."

echo " Usage: passwd [user]"

echo "49. whoami: Print the current user name."

echo " Usage: whoami"

echo "50. exit: Exit the shell."

echo " Usage: exit [status]"}


OUTPUT OR WORKING FOR EACH COMMAND IN ABOVE CODE

1. pwd: Print the current working directory.

Usage: pwd

2. ls: List directory contents.

Usage: ls [options] [path]

Options: -l (long format), -a (show hidden files)

3. cd: Change the current directory.

Usage: cd [directory]

4. cp: Copy files and directories.

Usage: cp [options] source destination

Options: -r (recursive), -i (interactive)

5. mv: Move or rename files and directories.

Usage: mv [options] source destination

Options: -i (interactive)

6. rm: Remove files or directories.


Usage: rm [options] file

Options: -r (recursive), -i (interactive)

7. touch: Create an empty file or update the timestamp.

Usage: touch filename

8. cat: Concatenate and display file contents.

Usage: cat [options] file

9. echo: Display a line of text.

Usage: echo [string]

10. man: Display the manual for a command.

Usage: man command

11. chmod: Change file permissions.

Usage: chmod [options] mode file

Options: + (add), - (remove), = (set)

12. chown: Change file owner and group.


Usage: chown [options] owner:group file

13. ps: Report a snapshot of current processes.

Usage: ps [options]

Options: aux (show all processes)

14. top: Display dynamic real-time information about running processes.

Usage: top

15. kill: Send a signal to a process.

Usage: kill [options] pid

16. grep: Search for patterns in files.

Usage: grep [options] pattern file

17. find: Search for files in a directory hierarchy.

Usage: find [path] [options]

18. df: Report file system disk space usage.

Usage: df [options]
Options: -h (human-readable)

19. du: Estimate file space usage.

Usage: du [options] [path]

Options: -h (human-readable), -s (summary)

20. free: Display memory usage.

Usage: free [options]

Options: -h (human-readable)

21. ifconfig: Configure a network interface.

Usage: ifconfig [interface] [options]

22. ip: Show/manipulate routing, devices, policy routing, and tunnels.

Usage: ip [options] [object] [command]

23. wget: Download files from the web.

Usage: wget [options] [URL]

24. curl: Transfer data from or to a server.


Usage: curl [options] [URL]

25. tar: Archive files.

Usage: tar [options] [file]

Options: -cvf (create), -xvf (extract)

26. zip: Package and compress files.

Usage: zip [options] zipfile files

27. unzip: Extract compressed files.

Usage: unzip [options] zipfile

28. history: Show command history.

Usage: history

29. alias: Create shortcuts for commands.

Usage: alias name='command'

30. unalias: Remove shortcuts for commands.

Usage: unalias name


31. echo: Display a line of text or variable value.

Usage: echo [string]

32. clear: Clear the terminal screen.

Usage: clear

33. nano: Simple text editor.

Usage: nano [file]

34. vi: Advanced text editor.

Usage: vi [file]

35. ssh: Secure Shell for remote login.

Usage: ssh [user@]hostname

36. scp: Securely copy files between hosts.

Usage: scp [options] source destination

37. rsync: Sync files/directories between locations.


Usage: rsync [options] source destination

38. df: Display free disk space.

Usage: df [options]

39. du: Display disk usage of files.

Usage: du [options] [path]

40. uname: Print system information.

Usage: uname [options]

41. hostname: Show or set the system's host name.

Usage: hostname [new_hostname]

42. reboot: Restart the system.

Usage: reboot

43. shutdown: Turn off the system.

Usage: shutdown [options] [time]


44. service: Start/stop/restart a service.

Usage: service service_name [start|stop|restart|status]

45. systemctl: Control the systemd system and service manager.

Usage: systemctl [options] command

46. journalctl: Query the systemd journal.

Usage: journalctl [options]

47. crontab: Schedule jobs to run periodically.

Usage: crontab [options] [file]

48. passwd: Change a user's password.

Usage: passwd [user]

49. whoami: Print the current user name.

Usage: whoami

50. exit: Exit the shell.

Usage: exit [status]

You might also like