Using Bash to Best Effect in Ubuntu El uso de bash para mejor efecto en Ubuntu
Basically, in the Bash environment, an administrator is working with text commands. Básicamente, en el entorno Bash, un administrador está trabajando con comandos de texto. An example of such a command is ls, which can be used to display a list of files in a directory. Un ejemplo de este tipo es un comando ls, que puede ser usado para mostrar una lista de archivos en un directorio. Bash has some useful features to make working with these line commands as easy as possible. Bash tiene algunas funciones útiles para hacer el trabajo con estos comandos de línea lo más fácil posible. Some shells offer the option to complete a command automatically. Algunas conchas ofrecemos la opción de completar un comando automáticamente. Bash has this feature, but it does more than just complete commands. Bash tiene esta característica, pero sí algo más que completar los comandos. Bash can complete almost everything: not just commands, but also file names and shell variables. Bash puede completar casi todo: no sólo los comandos, sino también los nombres de los archivos y las variables shell.
Using Automatic Command Completion El uso de la terminación automática de mando
Using this feature is as simple as pressing the Tab key. Con esta función es tan sencillo como pulsar la tecla Tab. For example, the cat line command is used to display the contents of an ASCII text file. Por ejemplo, el gato línea de comando se utiliza para mostrar el contenido de un archivo de texto ASCII. The name of this file, which is in the current directory, is this_is_a_file. El nombre de este archivo, que se encuentra en el directorio actual, es this_is_a_file. So, to open this file, the user can type cat thi and then press the Tab key. Por lo tanto, para abrir este archivo, el usuario puede escribir thi gato y, a continuación, pulse la tecla Tab. If the directory has only one file that starts with the letters thi, Bash automatically completes the name of the file. Si el directorio tiene un solo archivo que comienza con las letras thi, Bash completa automáticamente el nombre del archivo. If the directory has other files that start with the same letters, Bash will complete the name of the file as far as possible. Si el directorio tiene otros archivos que comiencen con las mismas letras, Bash completará el nombre del archivo en la medida de lo posible. For example, let’s say that there is a file in the current directory with the name this_is_a_text_file and another named thisAlsoIsAFile. Por ejemplo, digamos que hay un archivo en el directorio actual con el nombre this_is_a_text_file y otro llamado thisAlsoIsAFile. Because both files start with the text this, Bash will complete only up to this and no further. Porque ambos ficheros con el inicio de este texto, Bash completará sólo hasta esta y no más. To display a list of possibilities, you then press the Tab key again. Para mostrar una lista de posibilidades, a continuación, pulse la tecla Tab de nuevo. This allows you to manually enter more information. Esto le permite introducir manualmente más información. Of course, you can then use the Tab key again to use the completion feature once more. Por supuesto, puede usar la tecla Tab de nuevo a utilizar la terminación característica una vez más.
Working with the Tab key really makes the command line interface much easier. Trabajo con la tecla Tab realmente hace que la interfaz de línea de comandos mucho más fácil. Imagine that you need to manage logical volumes on your server and you remember only that the command for that starts with lv. Imagine que usted necesita para la gestión de volúmenes lógicos en su servidor y te acuerdas de que sólo el comando para que comienza con lv. In this case, you can type lv and press the Tab key twice. En este caso, puede escribir lv y pulse la tecla Tab dos veces. The result will be a nice list of all commands that start with lv, from which you’ll probably recognize the command that you need. El resultado será una bonita lista de todos los comandos que comienzan con lv, a partir de la cual usted probablemente reconoce el comando que usted necesita.
Working with Variables Trabajo con variables
A variable is simply a common value that is used often enough by the shell that it is stored with a name. Una variable es simplemente un valor común que se utiliza con frecuencia suficiente de la shell que se almacena con un nombre. An example of such a variable is PATH, which stores a list of directories that should be searched when a user enters a command. Un ejemplo de este tipo es una variable PATH, que almacena una lista de directorios que deben ser registrados cuando un usuario introduce un comando. To refer to the contents of a variable, prefix a $ sign before the name of the variable. Para referirse al contenido de una variable, un prefijo de dólares antes de firmar el nombre de la variable. For example, the command echo $PATH displays the content of the current search path that Bash is using. Por ejemplo, el comando echo $ PATH muestra el contenido de la actual ruta de búsqueda que utiliza Bash.
On any Linux system, you’ll get quite a few variables automatically. En cualquier sistema Linux, obtendrás un buen número de variables automáticamente. For an overview of all of them, you can use the env (short for environment) command. Para una visión general de todos ellos, puede usar el env (corto para el medio ambiente) de mando.
Normally, as a user, you’ll get your variables automatically when logging in to the system. Normalmente, como usuario, obtendrá sus variables automáticamente al acceder al sistema. The most important source of new variables is the /etc/profile file, a script that is processed for every user who logs in to the system. La fuente más importante de nuevas variables es el fichero / etc / profile, un script que es procesado por cada usuario que accede al sistema. Want to add a new variable? ¿Quieres añadir una nueva variable? Add it to the bottom of the /etc/profile file to make sure it is available for all users. Añadir a la parte inferior del fichero / etc / profile para asegurarse de que está disponible para todos los usuarios.
Working with Bash History Trabajo con la historia Bash
Another useful feature of the Bash shell is the history feature, which remembers and lets you reuse commands you have recently used. Otra característica útil de la shell Bash es la historia característica, que recuerda y te permite reutilizar los comandos que ha utilizado recientemente. By default, the last 1,000 commands are remembered. Por defecto, los últimos comandos 1000 son recordados. This feature is useful for sessions beyond even the current one. Esta función es útil para los períodos de sesiones, incluso más allá de la actual. A file, named .bash_history, is created in the home directory of every user, and this file records the last 1,000 commands that that user has entered. Un archivo, llamado. Bash_history, se crea en el directorio home de cada usuario, este archivo y registros de los últimos 1000 que los comandos que el usuario ha entrado. You can see an overview of these commands by typing history at the Bash prompt. Usted puede ver un resumen de estos comandos escribiendo la historia en el Bash prompt.
This is where the history feature becomes especially useful because you can reissue any command from this list without typing it all over again. Aquí es donde la historia se convierte en característica especialmente útil porque puede volver a cualquier comando de esta lista sin necesidad de escribir todo de nuevo. If you want to run any of the listed (and numbered) commands again, simply type its number preceded by an exclamation mark. Si deseas ejecutar cualquiera de los mencionados (y numeradas) comandos de nuevo, simplemente escriba su número precedido por un signo de exclamación. In this example, typing !5 would run aptitude show xen-source-2.6.16 again. En este ejemplo, escribiendo! 5 se ejecute aptitude show Xen-source-2.6.16. In addition to the history command, you can also use the up/down arrow keys, page up/down keys, and Ctrl+p/Ctrl+n to browse the history. Además de la historia de comandos, también puede utilizar el arriba / abajo teclas de cursor, arriba / abajo llaves, y Ctrl + p / Ctrl + n para navegar por la historia.
A user can also erase his or her history by using the history command. Un usuario también puede borrar de su historia mediante el uso de la historia de comandos. The most important option offered by this Bash internal command is the option -c, which clears the history list for that user. La opción más importante que ofrece este comando interno Bash es la opción-c, que borra la historia lista para ese usuario. This is especially useful because everything that a user types at the command line—such as passwords—is recorded. Esto es especialmente útil porque todo lo que un usuario introduce en la línea de comandos-como contraseñas-se registra. So use history -c to make sure your history is cleared if you’d rather not have others knowing what you’ve been up to. Por lo tanto, utilizar la historia-c para asegurarse de que su historia se borra si usted prefiere no tener otros a sabiendas de lo que ha sido hasta. Once using this option, however, you can’t use the arrow up key to access previous commands, because those are all erased. Una vez que utilice esta opción, sin embargo, no se puede usar la flecha clave para acceder a los comandos anteriores, porque esos son todos borrados. Because everything you enter from the command line is saved, I recommend never typing a plain-text password in the first place, even if you regularly erase the history. Porque todo lo que escriba desde la línea de comandos se guarda, recomiendo nunca a escribir una llanura contraseña de texto en primer lugar, incluso si regularmente borrar la historia. The commands that do require you to enter a password will prompt you anyway if you don't enter one right away. Los comandos que requieren que el usuario lo introduzca una contraseña se le preguntará si de todos modos no entran en una enseguida.
Source of Information : Apress Beginning Ubuntu Server Administration Fuente de información: Apress inicio Ubuntu Server Administración
Written by magakos. Escrito por magakos. Read more great feeds at is source Leer más grandes se alimenta de la fuente WEBSITE SITIO WEB
no comments No hay comentarios . .
Read more articles on Leer más artículos sobre Ubuntu Linux Ubuntu Linux and y otherSoftware otherSoftware . .
- [+] Digg [+] Digg : Feature this article : Reportaje este artículo
- [+] Del.icio.us [+] Del.icio.us : Bookmark this article : Guardar este artículo
- [+] Furl [+] Furl : Bookmark this article : Guardar este artículo















