Using Linux Commands

12
Using Linux Commands Lab 3

description

Using Linux Commands. Lab 3. 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 - PowerPoint PPT Presentation

Transcript of Using Linux Commands

Page 1: Using Linux Commands

Using Linux Commands

Lab 3

Page 2: Using Linux Commands

Checking system activityChecking 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.

$ ps au

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND

root 2164 0.0 0.8 1908 1100 ttyp0 S 14:50 0:00 login - - jake

jake 2147 0.0 0.7 1836 1020 ttyp0 S 14:50 0:00 -bash

jake 2310 0.0 0.7 2592 912 ttyp0 R 18:22 0:00 ps au

Page 3: Using Linux Commands

Checking system activityChecking system activity

To see and monitor all the processes running on the system :

use spacebar to page through , and q to end the list

$ ps aux | less

Page 4: Using Linux Commands

Checking system activityChecking system activity

To stop any process by PID i.e. to kill process

To stop all process except your shell

$ kill  2310

$ kill  0

Page 5: Using Linux Commands

Exiting the shell

To exit the shell

To logout the system

$ exit

$ logout

Page 6: Using Linux Commands

Using the Shell in LinuxUsing the Shell in LinuxCommands SyntaxCommands SyntaxOptions: Options:

could be added to the commands to change their behavior (-a , -la , --help)

Argument:Argument: is an extra piece of information (ex.: a file name)

Environment variables : Environment variables : where the shell stores information that may be useful to the user’s shell session.

(ex.: $HOME)

Meta characters: 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.

Page 7: Using Linux Commands

Getting Help with Using Getting Help with Using the Shellthe Shell

Use the help command )help command )

Use --help with the command (date --help)

Use the man command

Page 8: Using Linux Commands

Understanding file permission Why Why Keep users from accessing other users’ private files To protect important system files

permissions bitspermissions bits

rwx rwx rwxrwx rwx rwxOwner’sOwner’s|| Group Group || Others Others

r r == read read w w == write write x x == execute execute

$ ls –al

-rw-rw-r-- 1 chris sales 1024 May 10 01:49 ..

drwxr-xr-x 2 chris sales 2204 May 18 21:30 .bash_history

Page 9: Using Linux Commands

Change permission on a Change permission on a filefile For r, w, x octal value is 4,2,1 respectively

$ chmod 777 file-name rwxrwxrwx

$ chmod 755 file-name rwxr-xr-x

owner(u) group(g) other(o) all(a) rwxrwxrwx

$ chmod a-w file-name r-xr-xr-x

$ chmod go-rwx file-name rwx------

owner(u) group(g) other(o) all(a) ---------

$ chmod u+rw file-name rw-------

Page 10: Using Linux Commands

Creating files and directories1. Go to your home directory. Type cd.cd.2. Make sure that you got to your home directory, type pwdpwd3. Create a new directory called test in your home directory:

4. Check the permissions of the directory by typing:

5. Suppose that you want to prevent everyone else from using or viewing the files in this directory:

6. Make the test directory your current directory :

$ mkdir test

$ ls –ld test

drwxr-xr-x 2 chris sales 1024 May 18 21:30 test

$ chmod 700 test

$ cd test

Page 11: Using Linux Commands

Moving, copying, and deleting filesThe command mv moves (or renames) files. The simplest form of use

is mv mv oldfilename newfilenameoldfilename newfilename.

$ mv a.kwd b.kwd Renaming

It will also move directories. If you use it in the form

mv mv filenamefilename directorynamedirectoryname it will move the file into the named directory keeping its old name

$ mv a.kwd /mnt/collection1

$ mv /mnt/collection1/ a.kwd ~

Page 12: Using Linux Commands

Moving, copying, and deleting files

Copying files is similar to moving them but you use cp instead of mv

$ cp /mnt/collection1/ a.kwd /home/ahmed/Desktop

$ cp a.kwd /mnt/collection1

$ cp /mnt/collection1/ a.kwd ~

To remove a file you rm filename

$ rm a.kwd

$ rm *