[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.

Welcome to the Slackware Documentation Project

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
slackbook:bash [2012/09/08 18:00 (UTC)] – [Tab Completion] updated section to match original with formatting mfillpotslackbook:bash [2012/09/08 18:05 (UTC)] – [Terminals] updated section to match original with formatting mfillpot
Line 169: Line 169:
 ===== Input and Output Redirection ===== ===== Input and Output Redirection =====
  
-One of the defining features of Linux and other UNIX-like operating systems is the number of small, relatively simple applications and the ability to stack them together to create complex systems. This is achieved by redirecting the output of one program to another, or by drawing input from a file or second program.+One of the defining features of Linux and other UNIX-like operating 
 +systems is the number of small, relatively simple applications and the 
 +ability to stack them together to create complex systems.  This is 
 +achieved by redirecting the output of one program to another, or by 
 +drawing input from a file or second program. 
 + 
 + 
 +To get started, we're going to show you how to redirect the output of a 
 +program to a file.  This is easily done with the '>' character.  When 
 +**//bash//** sees the '>' character, it redirects 
 +all of the standard output (also known as stdout) to whatever file name 
 +follows. 
  
-To get started, we're going to show you how to redirect the output of a program to a file. This is easily done with the '>' character. When bash sees the '>' character, it redirects all of the standard output (also known as stdout) to whatever file name follows. 
 <code> <code>
 darkstar:~$ echo foo darkstar:~$ echo foo
Line 180: Line 191:
 </code> </code>
  
-In this example, we show you what echo would do if its stdout was not redirected to a file, then we re-direct it to the /tmp/bar file. If /tmp/bar does not exist, it is created and the output from echo is placed within it. If /tmp/bar did exist, then its contents are over-written. This might not be the best idea if you want to keep those contents in place. Thankfully, bash supports '>>' which will append the output to the file.+ 
 +In this example, we show you what **//echo//** would 
 +do if its stdout was not redirected to a file, then we re-direct it to 
 +the ''/tmp/bar'' file.  If ''/tmp/bar'' 
 +does not exist, it is created and the output from 
 +**//echo//** is placed within it.  If 
 +''/tmp/bar'' did exist, then its contents are 
 +over-written.  This might not be the best idea if you want to keep 
 +those contents in place.  Thankfully, **//bash//** 
 +supports '>>' which will append the output to the file. 
  
 <code> <code>
Line 194: Line 215:
 </code> </code>
  
-You can also re-direct the standard error (or stderr) to a file. This is slightly different in that you must use '2>' instead of just '>'. (Since bash can re-direct input, stdout, and stderr, each must be uniquely identifiable. 0 is input, 1 is stdout, and 2 is stderr. Unless one of these is specified, bash will make its best guess as to what you actually meant, and assumed anytime you use '>' you only want to redirect stdout. 1> would have worked just as well.)+ 
 +You can also re-direct the standard error (or stderr) to a file.  This 
 +is slightly different in that you must use '2>' instead of just '>'. 
 +(Since **//bash//** can re-direct input, stdout, and 
 +stderr, each must be uniquely identifiable.  0 is input, 1 is stdout, 
 +and 2 is stderr.  Unless one of these is specified, 
 +**//bash//** will make its best guess as to what you 
 +actually meant, and assumed anytime you use '>' you only want to 
 +redirect stdout.  1> would have worked just as well.) 
  
 <code> <code>
Line 204: Line 234:
 </code> </code>
  
-You may also redirect the standard input (known as stdin) with the '<' character, though it's not used very often.+ 
 +You may also redirect the standard input (known as stdin) with the 
 +'<' 
 +character, though it's not used very often. 
  
 <code> <code>
Line 210: Line 244:
 </code> </code>
  
-Finally, you can actually redirect the output of one program as input to another. This is perhaps the most useful feature of bash and other shells, and is accomplished using the '|' character. (This character is referred to as 'pipe'. If you here some one talk of piping one program to another, this is exactly what they mean.)+ 
 +Finally, you can actually redirect the output of one program as input 
 +to another.  This is perhaps the most useful feature of 
 +**//bash//** and other shells, and is accomplished 
 +using the '|' character.  (This character is referred to as 'pipe'. 
 +If you here some one talk of piping one program to another, this is 
 +exactly what they mean.) 
  
 <code> <code>
Line 220: Line 261:
 root      3202  0.0  0.0   1660   536 tty6     Ss+  Feb15   0:00 /sbin/agetty 38400 tty6 linux root      3202  0.0  0.0   1660   536 tty6     Ss+  Feb15   0:00 /sbin/agetty 38400 tty6 linux
 </code> </code>
- 
 ===== Task Management ===== ===== Task Management =====
  
-bash has yet another cool feature to offer, the ability to suspend and resume tasks. This allows you to temporarily halt a running process, perform some other task, then resume it or optionally make it run in the background. Upon pressing CTRL-Z, bash will suspend the running process and return you to a prompt. You can return to that process later. Additionally, you can suspend multiple processes in this way indefinitely. The jobs built-in command will display a list of suspended tasks.+**//bash//** has yet another cool feature to offer, 
 +the ability to suspend and resume tasks.  This allows you to 
 +temporarily halt a running process, perform some other task, then 
 +resume it or optionally make it run in the background. Upon pressing 
 +<key>CTRL-Z</key>**//bash//** will suspend 
 +the running process and return you to a prompt. You can return to that 
 +process later.  Additionally, you can suspend multiple processes in 
 +this way indefinitely.  The **//jobs//** built-in 
 +command will display a list of suspended tasks. 
  
 <code> <code>
Line 231: Line 280:
 </code> </code>
  
-In order to return to a suspended task, run the fg built-in to bring the the most recently suspended task back into the foreground. If you have mutiple suspended tasks, you can specify a number as well to bring one of them to the foreground.+ 
 +In order to return to a suspended task, run the 
 +**//fg//** built-in to bring the the most recently 
 +suspended task back into the foreground. If you have mutiple suspended  
 +tasks, you can specify a number as well to bring one of them to the 
 +foreground. 
  
 <code> <code>
Line 238: Line 293:
 </code> </code>
  
-You can also background a task with (surprize) bg. This will allow the process to continue running without maintaining control of your shell. You can bring it back to the foreground with fg in the same way as suspended tasks.+ 
 +You can also background a task with (surprize) 
 +**//bg//**. This will allow the process to continue 
 +running without maintaining control of your shell. You can bring it 
 +back to the foreground with **//fg//** in the same 
 +way as suspended tasks.
  
 ===== Terminals ===== ===== Terminals =====
  
-Slackware Linux and other UNIX-like operating systems allow users to interact with them in many ways, but the most common, and arguably the most useful, is the terminal. In the old days, terminals were keyboards and monitors (sometimes even mice) wired into a mainframe or server via serial connections. Today however, most terminals are virtual; that is, they exist only in software. Virtual terminals allow users to connect to the computer without requiring expensive and often incompatible hardware. Rather, a user needs only to run the software and they are presented with a (usually) highly customizable virtual terminal.+Slackware Linux and other UNIX-like operating systems allow users to 
 +interact with them in many ways, but the most common, and arguably the 
 +most useful, is the terminal. In the old days, terminals were keyboards 
 +and monitors (sometimes even mice) wired into a mainframe or server via 
 +serial connections. Today however, most terminals are virtual; that is, 
 +they exist only in software.  Virtual terminals allow users to connect 
 +to the computer without requiring expensive and often incompatible 
 +hardware. Rather, a user needs only to run the software and they are 
 +presented with a (usually) highly customizable virtual terminal. 
  
-The most common virtual terminals (in that every Slackware Linux machine is going to have at least one) are the gettys. agetty(8) runs six instances by default on Slackware, and allows local users (those who can physically sit down in front of the computer and type at the keyboard) to login and run applications. Each of these gettys is available on different tty devices that are accessible seperately by pressing the **ALT** key and one of the function keys from **F1** through **F6**. Using these gettys allows you to login multiple times, perhaps as different users, and run applications in those users' shells silmutaneously. This is most commonly done with servers which do not have X installed, but can be done on any machine.+The most common virtual terminals (in that every Slackware Linux machine 
 +is going to have at least one) are the gettys. 
 +**//agetty//**(8) runs six instances by default on 
 +Slackware, and allows local users (those who can physically sit down in 
 +front of the computer and type at the keyboard) to login and run 
 +applications. Each of these gettys is available on different tty 
 +devices that are accessible seperately by pressing the 
 +<key>ALT</key> key and one of the function keys from 
 +<key>F1</key> through <key>F6</key>. Using these gettys 
 +allows you to login multiple times, perhaps as different users, and run 
 +applications in those users' shells silmutaneously. This is most 
 +commonly done with servers which do not have 
 +**//X//** installed, but can be done on any machine.
  
-On desktops, laptops, and other workstations where the user prefers a graphical interface provided by X, most terminals are graphical. Slackware includes many different graphical terminals, but the most commonly used are KDE's konsole and XFCE's Terminal(1) as well as the old standby, xterm(1). If you are using a graphical interface, check your tool bars or menus. Each desktop environment or window manager has a virtual terminal (often called a terminal emulater), and they are all labelled differently. Typically though, you will find them under a "System" sub-menu in desktop environments. Executing any of these will give you a graphical terminal and automatically run your default shell. 
  
 +On desktops, laptops, and other workstations where the user prefers a
 +graphical interface provided by **//X//**, most
 +terminals are graphical.  Slackware includes many different graphical
 +terminals, but the most commonly used are KDE's
 +**//konsole//** and XFCE's
 +**//Terminal//**(1) as well as the old standby,
 +xterm(1). If you are using a graphical interface, check your tool bars
 +or menus. Each desktop environment or window manager has a virtual
 +terminal (often called a terminal emulater), and they are all labelled
 +differently. Typically though, you will find them under a //"System"//
 +sub-menu in desktop environments. Executing any of these will give you
 +a graphical terminal and automatically run your default shell.
 ===== Customization ===== ===== Customization =====
  
 slackbook:bash ()