1 / 19

Using Linux Commands

Using Linux Commands. Lab 4. Checking directories and permissions. To find out what your current directory is: To find out the name of your home directory:. To get back to your home directory: To change the current directory to the directory that you choose:.

Télécharger la présentation

Using Linux Commands

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Using Linux Commands Lab 4

  2. Checking directories and permissions • To find out what your current directory is: • To find out the name of your home directory:

  3. To get back to your home directory: • To change the current directory to the directory that you choose:

  4. To list the contents of the current directory: File & Directory Commands DateThe date of last modification permissions UserThe user that owns the file, or directory SizeThe size in bytes GroupThe group that file belongs to, Directories This field specifies the number of links or directories inside this directory. Directory or FileThe name of the file or directory.

  5. File & Directory Commands • To list files across the page, separated by commas: • To list the contents of subdirectories: • List the contents of your home directory • List the contents of your root directory

  6. File & Directory Commands

  7. Checking system activity • To list running processes and monitoring system usage: • a option ask to show process of all users who are associated with your current terminal • u option asks that user names be shown , as well as other information such as the time process started and CPU usage. • VSZ (virtual set size)  size of image process(in kilobytes). • RSS(resident set size) size of program in memory.

  8. Checking system activity • To see and monitor all the processes running on the system : use spacebar to page through , and q to end the list

  9. Checking system activity • To stop any process by PID i.e. to kill process • To stop all process except your shell

  10. 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.

  11. Getting Help with Using the Shell • Use --help with the command(date --help) • Use theman command • man = manual • To reading a manual and return to the shell prompt within the open terminal  press q

  12. 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

  13. 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

  14. 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.

  15. 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.

  16. 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-

  17. 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.

  18. 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)---------

  19. Reference • žRed Hat Linux Bible: Fedora and Enterprise Edition by Christopher Negus  • Chapter 4 • žhttp://book.chinaunix.net/special/ebook/RedHat_Linux_Bible/8140final/toc.html

More Related