Presentation is loading. Please wait.

Presentation is loading. Please wait.

5 Basic utilities When a user logs in to the Linux operating system the directory that they will start in is their home directory. Most users will have.

Similar presentations


Presentation on theme: "5 Basic utilities When a user logs in to the Linux operating system the directory that they will start in is their home directory. Most users will have."— Presentation transcript:

1 5 Basic utilities When a user logs in to the Linux operating system the directory that they will start in is their home directory. Most users will have /home/userid as their home directory. The root user has /root as it’s home directory.

2 ls Lists the names of files ls –l ls –la
To view the contents of the current directory you can type: ls –l The –l option says to give a long list which includes file permissions, owner, group, size (in bytes), date created, and filename. ls –la You can view the hidden system files by including the –a option:

3 To view the contents of the /var/log directory type: ls /var/log
You can include a path instead of just a filename to list. For example to view the contents of the / directory you can type: ls / Notice the –l option was not used so the directory will display only the file and directory names, not the properties. To view the contents of the /var/log directory type: ls /var/log

4 cat Displays a Text File

5 rm Deletes a file rm filename Rm –i filename have to hit y to remove
To remove a directory use the rmdir command. rmdir scripts You must have write permission to remove a directory.

6 To remove a directory that has other files within it use the rm command with the –r option (recursive). To remove the /etc/skel/cron directory and any files and directories that may be within it type: rm –r /etc/skel/cron To remove one or more files use the rm command. To remove the file Welcome from the /etc/skel directory type: rm /etc/skel/Welcome

7 less Display a text file one screen at a time

8 hostname Displays the system name

9 Copying a file from the CLI
Copy files with the cp command. When you copy a file you duplicate the file and it’s contents to another file. Filenames must be unique so if you copy the file to the same directory it must have a different name. To copy /root/myFile to the / directory type: cp /root/myFile /myFile

10 Copying a file from the CLI
Copy files with the cp command. To copy /root/myFile to the / directory with the name myFile2 type: cp /root/myFile /myFile2 You can use wildcards with filenames as you did with the ls command. To copy /myFile and /myFile2 to the /root directory type: cp /myfile* /root If you are replacing an existing file you will be prompted if it can be overwritten.

11 Moving a File from the CLI
To move a file use the mv command. When you move a file to another file in the same directory you are essentially renaming the file. To move /root/myFile to /root/myFile2 type: mv /root/myFile /root/myFile2 To move /root/myFile2 to /myFile type: mv /root/myFile2 /myFile To move /myFile to /root/myFile type: mv /myFile /root/myFile You must have read and write permissions to move a file.

12 lpr Prints a file

13 grep allows user to search for occurrence of
a string of characters in a file

14 Head and Tail head Display the beginning of a file (the first 10 lines) Tail Display the end of a file (the last ten lines)

15 sort displays the lines of a file in order

16 uniq removes duplicate lines

17 echo copies the command line (but not the word echo) to the screen

18 Compressing and Archiving
bzip2 bunzip2 gzip tar

19 who lists who is logged in

20 finger: lists who is logged in

21 Figure 5-19 Entering text with vim

22 Figure 5-20 The main vim Help screen

23

24 Figure 5-21 Help with insert commands

25 File system When a user logs in to the Linux operating system the directory that they will start in is their home directory. Most users will have /home/userid as their home directory. The root user has /root as it’s home directory. Type pwd to display the path

26 Linux File System Structure
The file system structure used by Linux is a hierarchal list of directories called a directory tree. The top of the tree is the root directory indicated by a /. The upper directories are called parent directories and the directories beneath them are called child directories.

27 Figure 6-5 Absolute pathnames

28 Figure 6-6 Relative pathnames

29

30 Changing and Viewing Directories from the CLI
Although you can view the contents of any directory from anywhere in the file system hierarchy you can also change to the individual directories. To change the current directory to the / directory type: cd / To change to jsmith’s Documents directory within his home directory type: cd /home/jsmith/Documents There are shortcut commands you can also use. For example, you can use the shortcut .. change to the parent directory of the current directory by typing: cd ..

31 Changing and Viewing Directories from the CLI
You can change to your home directory with the shortcut ~ by typing: cd ~ (or just cd without any options) The root user goes back to /root with this command. You can display the current directory by typing the pwd command.

32 Linux File System Structure
In order to find files within the file system, a standard exists that identifies where certain types of files go. This standard is the file system Hierarchy Standard (FHS) maintained by the file system Hierarchy Standard Group. The standard contains a set of requirements and guidelines for file and directory placement under UNIX-like operating systems. Use of the FHS provides interoperability of applications, system administration tools, development tools, and scripts. The FHS defines many common directories used in UNIX-like operating systems.

33 Linux File System Structure
/ - The root directory is the top of the file system hierarchy. The contents of the root file system must contain all the files needed to boot, restore, recover, and repair the system. /bin - The /bin directory contains commands used by the system administrator and other users. These are required commands when no other filesystems are mounted. /boot - The /boot directory contains all files, except configuration files, needed to boot the operating system. The /boot stores data that is used before the kernel begins executing user-mode programs.

34 Linux File System Structure
/dev - The /dev directory contains file system entries which represent devices that are part of the system. /etc - The /etc directory contains local configuration files. No binaries are contained within /etc. /home - The /home directory contains user directories. The /home directory is optional. Typically, the /home directory contains a subdirectory for each user added to the system.

35 Linux File System Structure
/lib - The /lib directory contains shared library images need to boot the system and run the commands in the root filesystem. /opt - The /opt directory contains add-on application software packages. /proc - The /proc file system is used to handle storage and retrieval of process information.

36 Linux File System Structure
/root - The /root directory is the home directory of the root user. /sbin - The /sbin directory contains utilities used for system administration. These utilities are executed after /usr is known to be mounted and there are no problems. /tmp - The /tmp directory contains temporary files. These files are lost if the system restarts.

37 Linux File System Structure
/usr - The /usr directory contains files that can be shared across all hosts. This directory is mounted read-only and contains the following subdirectories or symbolic links to directories: /usr/bin – contains most user commands /usr/include – contains header files included by C programs /usr/lib – contains libraries /usr/local – local hierarchy /usr/sbin – contains non-vital system binaries /usr/share – contains architecture-independent data

38 Linux File System Structure
/var - The /var directory contains variable data files. This includes spool directories, log files, and temporary files. Some directories within /var are sharable and some are unsharable. The following directories are required in /var: /var/cache – contains application cache data /var/lib – contains variable state information /var/local – contains data for /usr/local /var/lock – contains lock files /var/log – contains log files and directories /var /opt - contains variable data for /opt /var/run – contains data relevant to running processes /var/spool – contains application spool data /var/tmp – contains temporary files preserved between system reboots

39 Permissions Every file or directory has a set of permissions that determines who can access and what they can do to the file. Permissions are represented by the characters r, w, and x which represent read, write, and execute. The r, w, and X have a different meaning depending if it is assigned to a file or a directory. r with a file means the file can be displayed or copied, with a directory means it can be listed. w with a file means the file can be changed, with a directory means it can be created or deleted. x means a file can be executed (script or program), with a directory allows files within it to be copied or moved.

40 Permissions For example:
-rwx indicates a file that has read, write, and execute permissions for the owner only. -r-xr-xr-x indicates a file that has read and execute permissions for the owner, group, or anyone else. drwxr-x—x indicates a directory that allows read, write, and execute permission for the owner, read and execute for the group, and execute only for everyone else.

41 Permissions Permissions can also be viewed as octal numbers.
r permission is represented by 4 w permission is represented by 4 x permission is represented by 1 Permissions 777 means r, w, and x permissions are enabled for the user, the user’s groups, and all others Permissions 541 means the user has r, and x permissions, the user’s group has only r permission, and all others have just x permissions.

42 The permission list, -rwxr-xr-x is treated as a block of binary digits, a bitfield. Translating this into octal, we would get 0755, which is base 2. We can then represent each permission for each user type by a single octal digit (plus an extra digit for the first bit). 400 -r read by owner r----- read by group r-- read by anybody (other) 200 --w write by owner w---- write by group w- write by anybody x execute by owner x--- execute by group x execute by anybody 4000 s suid 2000 s sgid 1000 t sticky These permissions on their own may not be very useful, but we can add the octal numbers to get a combination of permissions. For example, 4, which corresponds to r-- (for some user type), and 2, which corresponds to -w- (for some user type), can be added to get 6, 110 in binary, which corresponds to rw-, read and write. Note also that in a group of three octal digits, the "place" of the digit signifies where we assign the permission. 600 octal, in binary is , so we are setting read and write permissions for us, but not the group or other users. 060 octal, in binary however is , and sets it for the group only, and likewise. So, for example, if we want to set read and write for ourselves and the group, and have no permissions whatsoever for the other users, we could use the permission 660.

43 Changing Permissions with the CLI
Change permissions for group and others to read and execute using octal numbering: chmod 755 IT250 You can also use chmod to add or remove specific permissions chmod u+w IT would add w permission for the user. chmod a-x IT would remove x permission for all (a) users.

44 Links A pointer to a file

45 Hard Links A pointer to a file – the directory entry points to the inode


Download ppt "5 Basic utilities When a user logs in to the Linux operating system the directory that they will start in is their home directory. Most users will have."

Similar presentations


Ads by Google