SlideServe
Menu
Préférences
© SlideServe · v2026

Mastering Linux Shell Commands: Syntax, Permissions, and File Management

blake-house avatar
43 diapositives · 576 Views · Nov 18, 2014

This guide provides an in-depth understanding of using shell commands in Linux, focusing on command syntax, options, arguments, and environment variables (like $SHELL and $PS1). Learn to manipulate file permissions with commands like `chmod`, understand the significance of `rwx` bits, and create, move, and delete files and directories. It also covers essential file-matching metacharacters, enhancing your command line efficiency. Become proficient in managing your Linux environment effectively.

Mastering Linux Shell Commands: Syntax, Permissions, and File Management - slide 1
01 / 43Mastering Linux Shell Commands: Syntax, Permissions, and File Management
1 / 17

Télécharger la présentation

Mastering Linux Shell Commands: Syntax, Permissions, and File Management
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Using Linux Commands Lab 4

  2. Using the Shell in LinuxCommands Syntax • Options: could be added to the commands to change their behavior(-a , -la , --help) • Argument: is an extra piece of information(ex.: a file name) • Environment variables : where the shell stores information that may be useful to the user’s shell session. Examples of environment variables include $SHELL (which identifies the shell you are using )and$PS1 (which defines your shell prompt) Meta characters: that have special meaning to the shell • (>) used to direct the output of a command to a file. • ( | ) pipe the output to another command.

  3. Environment variables :

  4. Getting Help with Using the Shell • Use --help with the command(date --help)

  5. Use theman command • man = manual • To reading a manual and return to the shell prompt within the open terminal  press q

  6. Understanding file permission • Why • Keep users from accessing other users’ private files • To protect important system files • permissions bits rwx rwx rwx Owner’s| Group | Others r = read w = write x = execute

  7. Understanding file permission For Files: • "Read" means to be able to open and view the file • "Write" means to overwrite or modify the file • "eXecute" means to run the file as a binary files are executable only if they are programs and shell scripts, not useful for data files. For Directories: • "Read" means to be able to view the contents of the directory • "Write" means to be able to create new files/directories or delete files/directories within the directory • "eXecute" means to be able to "Change Directory" (cd) into the directory = permission to access the directory. • How to view the permission for a file or directory? • $ ls -al

  8. Understanding file permission d ≡ directory -≡ file Permission for the group Permission for the others Permission for the owner • if the permission field is -  the permission is not given.

  9. Understanding file permission • Only the owner of a file can change its permission. • How to set file permission? • Use the command chmod(change file mode bits). • chmod has two notations: • Numeric(octal) notation. • Symbolic notation.

  10. Change permission on a file - numeric • the file permissions aren't represented by characters. Instead, they are represented by a three-digit octal number. • 4 = read (r)2 = write (w)1 = execute (x)0 = no permission (-) If the permission is 725 4+2+1 0+2+0 4+0+1 r-x rwx -w-

  11. Change permission on a file – symbolic • Permissions are represented by characters rwx • This gives “who” the specified permissions for a given filename. • The “who” is a list of letters re going to be giving permissions to. These may be specified in any order. • +  add the selected permission. • -  remove the selected permission.

  12. Change permission on a file For r, w, x octal value is 4,2,1 respectively owner(u) group(g) other(o) all(a)rwxrwxrwx owner(u) group(g) other(o) all(a)---------

  13. Set different permissions of start file:

  14. Creating files and directories • Use the command mkdir to create a new directory to the current working directory. • $ mkdirdirectoryName

  15. Creating directories (Exercise) • Go to your home directory. Type cd. • Make sure that you got to your home directory, type pwd • Create a new directory called test in your home directory: • Check the permissions of the directory by typing: ((The -d option tells ls not to list the contents of the test directory; just show us the listing for the directory itself)). • Suppose that you want to prevent everyone else from using or viewing the files in this directory: • Make the test directory your current directory :

  16. Answer

  17. Creating directories • To create a directory(test) in the Desktop, we have two ways: • mkdir /home/chris/Desktop/test • cd /home/chris/Desktopmkdir test • NOTE: • The -d option tells ls not to list the contents of the test directory; just show us the listing for the directory itself.

  18. Moving, copying, and deleting files

  19. Rename file start start1

  20. After rename the file

  21. Moving, copying, and deleting files *  remove all files in the current directory

  22. Before remove application file.

  23. After remove application file.

  24. Winows file before and after (cp command )

  25. Create empty files • To create an empty file in the current directory use the command touch • $ touch file1 file2 file3 Using file-matching metacharacters • Metacharacters help to match one or more files without typing each filename completely. • * This matches any number of characters(zero or more characters). • ? This matches any one(single) character. • […] This matches any one of the characters between the brackets, which can include a dash-separated rang of letters or numbers.

  26. Using file-matching metacharactersThis matches any number of characters *

  27. Using file-matching metacharactersThis matches any one(single) character?

  28. Using file-matching metacharactersThis matches any one of the characters between the brackets […]

  29. Using file-redirection metacharacters • < Direct the contents of a file to the command • > Direct the output of a command to a file, overwriting any existing file • >> Direct the output of a command to a file, adding the output to the end of • existing file

  30. echo Command • Use echo command to display text or value of variable. echo [options] [string, variables...]

  31. Quotes • "Double Quotes“ • variables and command substitution(except \and $). • 'Single quotes‘ • protects everything enclosed between two single quote marks. • It is used to turn off the special meaning of all characters ( NOsubstitution of variables and commands). • `Back quote` • Used with commands only. • To execute command.

  32. echo Command • Options-nDo not output the trailing new line.-eEnable interpretation of the following backslash escaped characters in the strings: \a alert (bell)\b backspace\n new line\t horizontal tab

  33. Examples of quoting special characters

  34. References http://www.podgrid.org/linux-bible/linux-bible-page109.html