<--Chapter 20 Table of Contents Appendix B-->  

 

Appendix A: The Linux Shell

The default Linux shell is bash.  Here's a summary of common bash shell commands.

ls— lists the files in the current directory

[root@armitage temp]# ls
typescript

touch — create a new, blank file.  If the file exists, changes the time it was last modified but otherwise leaves the file unchanged.

[root@armitage temp]# touch temp.txt
[root@armitage temp]# ls
temp.txt    typescript

rm — permanently remove a file

[root@armitage temp]# rm temp.txt
rm: remove `temp.txt'? y

Note: Red Hat defines aliases for rm, mv and cp that prompt before they overwrite or erase a file.  Most other distributions use the default behaviour, which is to take action without warning.  You can disable Red Hat's aliases with the unalias command.

mv — change the name of a file, or move it to a new location

[root@armitage temp]# touch temp.txt
[root@armitage temp]# mv temp.txt temp2.txt
[root@armitage temp]# ls
temp2.txt   typescript

cp — copy a file

[root@armitage temp]# cp temp2.txt temp3.txt
[root@armitage temp]# ls
temp2.txt   temp3.txt   typescript

grep — search a file for a word or phrase

[root@armitage temp]# grep "procedure" /home/ken/ada/basicio2.adb
procedure basicio2 is

find — search for a file

[root@armitage temp]# find /home/ken -type f -name basicio3.adb
/home/ken/ada/basicio3.adb

lpr — print a file

[root@armitage temp]# lpr basicio3.adb

lprm — stop printing a file, if the file hasn't started printing yet

[root@armitage temp]# lprm
dfA017Aa01370 dequeued
cfA017Aa01370 dequeued

lpq — list your files waiting to be printed

[root@armitage temp]# lpq
no entries

cat — display a file

[root@armitage temp]# cat hello.adb
with Ada.Text_IO;
use Ada.Text_IO;

procedure hello is
begin
  Put_Line( "Hello world!" );
end hello;

less — display a file one screen at a time, allowing you to move around

[root@armitage temp]# less basicio.adb

tr — translate characters.  To translate a DOS text file to a Linux text file, use

tr —d ‘\r' < dos.txt > linux.txt
 

  <--Chapter 20 Table of Contents Appendix B-->