180 likes | 348 Views
Module 6: The Command Line. We will learn more commands for managing files and directories. Understanding file management. File Listings Normal files Directory files – a special instance of normal files. File Ownerships File Permissions. Listing File.
E N D
Module 6: The Command Line • We will learn more commands for managing files and directories Module 6: The command line
Understanding file management • File Listings • Normal files • Directory files – a special instance of normal files. • File Ownerships • File Permissions Module 6: The command line
Listing File ls with option) – list all the files in a directory. • ls [-option] filename -l long listing -a all files -1 single column listing (number) Module 6: The command line
Changing Files’ setting • Changing ownership: chown – to change the ownership of a file to someone else. • Changing Groups: chgrp – to change the group settings • Change Mode: chmod - used to set permission values. Module 6: The command line
Permissions • Permissions are divided into four parts: part1 part2 part3 part4 - rwx rwx rwx Example: -rwxr-xr-- Module 6: The command line
Part1 • “-” file • “d” directory • “l” link Module 6: The command line
Part2, Part3, Part4 letter permission value • “r” read 4 • “w” write 2 • “x” execute 1 Module 6: The command line
Managing files • Copy files: cp [-f, -i] • Moving files: mv [-f, -i] • Linking files: ln [-s] • Finding a file: find satrt_dir [option] locate • Converting and Copying a file: dd [if, of, …] Module 6: The command line
Managing files (cont.) • File compression: gzip [-c, -d]; tar [-c, -x, -z] • Displaying the contents of text files: cat • Displaying a file One Screen at a time: more; less • Locating a Command: whereis Module 6: The command line
Managing directories • Change directory: cd • Creating a directory: mkdir • Removing Directory (empty): rmdir • Showing Present Working Directory: pwd Module 6: The command line
Getting help & finding commands • man – format and display the on-line manual • info – read info documents • whatis – search the whatis database for complete words. Module 6: The command line
Showing Disk information • Disk Utilization: du [-h, -k] • Disk Free: df [-h, -l] Module 6: The command line
Tracking and Terminating Processes • Listing processes: ps [-a, -r, -u, -l] -a all processes -r running processes only -u the process owners -l long format of a list Module 6: The command line
Tracking and Terminating Processes (cont.) • Showing an interactive List of Processes: top • Sending a signal to a Process: kill -n Module 6: The command line
Editing Text Files • vi editor • Start vi vi filename • Save text :w • Exit vi :q (exit vi after saving text) :q! (exit vi without saving) Module 6: The command line
Redirection • Take the output of a program and sent to a file automatically. command > filename > output to a file >> append to a file < send a file as input Module 6: The command line
Pipes • The output of a program can be sent as the input to another program. • “ | “ • Example: printenv | grep “HOME” • grep utility • Input from another program to match the given thing and display the only matching lines. • searching both file contents and filenames Module 6: The command line
Summary • General management tools • |; grep; man; whereis • File management commands • ls; cat; more; find; chown; chgrp; chmod • Directory management commands • cd; mkdir; rmdir; pwd • Disk management commands • du; df • Process management commands • ps; kill Module 6: The command line