140 likes | 236 Views
Linux commands – part 3. CS 302. Sort. Sort the lines of text files . $ sort fileName by default it will sort in normal order(0-9 A-Z ). Options -r Reverse normal order(reverse alphabetical Z-A 9-0). -n Sort in the following order ( A-Z 0-9 )
E N D
Linux commands – part 3 CS 302
Sort • Sort the lines of text files. $ sort fileName • by default it will sort in normal order(0-9 A-Z ). • Options -rReverse normal order(reverse alphabetical Z-A 9-0). -nSort in the following order (A-Z 0-9) -nrSort in reverse of –n (9-0 Z-A) • Note that this command does not sort the actual file, it just displays the sorted output on your terminal.
Count words • Short for word count, • wcdisplays a count of lines, words, and characters in a file.
Date Display date. • Show current date & time $ date • The following command takes an inputdate only string, and displays the output in date format $date --date=“2001-3-15”
Date • Setdate. $ date –s “date to be changed”
Calendar • Prints out a formatted calendar of the current month, or a specified month, or a specified whole year. • $ cal • $cal 2001
History • Print the history of used commands. $ history • This command will display the last n commands in your history: (n is a number) $ history n
Sequential commands • To run a sequence of commands type several commands on the same command line and separating them with semicolons(;) • $pwd ; ls
Alias • Alias command allows a user to create simple names for any command (even sequential one) then use them in the same way that ordinary commands are used. • To create a simple name for pwd command : • alias p="pwd“ • To create a simple name for Is –al command: • alias ls="ls -al“ • To create a simple name for a sequential command pwd; ls : • alias pl='pwd; ls • To remove the simple name , use the command unailias • unalias pl='pwd; ls
Free disk • Report how much free disk space is available for each mount you have • To list all file systems and their used and available space • $ df • To displays the free disk information in a readable format: • $ df -h
Logout • This command allows user to logout from the system. • % logout
Process management • What is a UNIX Process? • A process in Linux is an executing command or program. • The process is what actually performs the work of the command or program. • A process is created every time you run a command or program from the command line. • For example, when you execute a simple command like ls, a single process is created .
Process management • To get a report about the current processes • % ps • The above command will list all current processes to you with these information:
Process management • To kill one of these processes • $ kill -9 4460 (where 17525 is the PID).