Using Bash to Best Effect in Ubuntu Bash utilizzando al meglio in Ubuntu
Basically, in the Bash environment, an administrator is working with text commands. In sostanza, nella Bash ambiente, l'amministratore sta lavorando con i comandi di testo. An example of such a command is ls, which can be used to display a list of files in a directory. Un esempio di questo tipo è un comando ls, che può essere utilizzato per visualizzare un elenco di file in una directory. Bash has some useful features to make working with these line commands as easy as possible. Bash ha alcune caratteristiche utili per lavorare con questi comandi in linea il più semplice possibile. Some shells offer the option to complete a command automatically. Alcune conchiglie offerta la possibilità di completare automaticamente un comando. Bash has this feature, but it does more than just complete commands. Bash ha questa funzione, ma non solo completare i comandi. Bash can complete almost everything: not just commands, but also file names and shell variables. Bash in grado di completare quasi tutto: non solo i comandi, ma anche nomi di file e le variabili della shell.
Using Automatic Command Completion Utilizzando il completamento automatico di comando
Using this feature is as simple as pressing the Tab key. Utilizzando questa funzione è semplice come premere il tasto Tab. For example, the cat line command is used to display the contents of an ASCII text file. Per esempio, il gatto linea di comando è usato per visualizzare il contenuto di un file di testo ASCII. The name of this file, which is in the current directory, is this_is_a_file. Il nome di questo file, che è nella directory corrente, è this_is_a_file. So, to open this file, the user can type cat thi and then press the Tab key. Così, per aprire il file, l'utente può digitare cat thi e premere il tasto Tab. If the directory has only one file that starts with the letters thi, Bash automatically completes the name of the file. Se la directory è solo un file che inizia con le lettere thi, bash completa automaticamente il nome del file. If the directory has other files that start with the same letters, Bash will complete the name of the file as far as possible. Se la directory ha altri file che iniziano con le stesse lettere, bash completerà il nome del file il più possibile. 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. Per esempio, diciamo che c'è un file nella directory corrente con il nome this_is_a_text_file e un'altra chiamata thisAlsoIsAFile. Because both files start with the text this, Bash will complete only up to this and no further. Perché entrambi i file iniziano con il testo presente, bash completerà solo fino al presente e non oltre. To display a list of possibilities, you then press the Tab key again. Per visualizzare un elenco di possibilità, quindi premere il tasto Tab. This allows you to manually enter more information. Ciò consente di inserire manualmente ulteriori informazioni. Of course, you can then use the Tab key again to use the completion feature once more. Naturalmente, potete quindi utilizzare il tasto Tab di nuovo per utilizzare la funzionalità di completamento ancora una volta.
Working with the Tab key really makes the command line interface much easier. Lavorare con il tasto Tab davvero fa la linea di comando molto più facile. Imagine that you need to manage logical volumes on your server and you remember only that the command for that starts with lv. Immaginate che avete bisogno di gestire volumi logici sul server e si ricorda che solo per il comando che inizia con lv. In this case, you can type lv and press the Tab key twice. In questo caso, è possibile digitare lv e premere il tasto Tab due volte. 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. Il risultato sarà una bella lista di tutti i comandi che iniziano con lv, da cui verrà probabilmente riconoscere il comando di cui avete bisogno.
Working with Variables Lavorare con Variabili
A variable is simply a common value that is used often enough by the shell that it is stored with a name. Una variabile è semplicemente un valore comune che viene utilizzato abbastanza spesso di shell che viene salvato con un nome. 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 esempio di questo tipo è una variabile PATH, che memorizza un elenco di directory che dovrebbe essere ricerche quando un utente inserisce un comando. To refer to the contents of a variable, prefix a $ sign before the name of the variable. Fare riferimento al contenuto di una variabile, $ prefisso prima di firmare il nome della variabile. For example, the command echo $PATH displays the content of the current search path that Bash is using. Per esempio, il comando echo $ PATH visualizza il contenuto dell 'attuale percorso di ricerca che sta utilizzando Bash.
On any Linux system, you’ll get quite a few variables automatically. Su qualsiasi sistema Linux, si otterrà un bel po 'variabili automaticamente. For an overview of all of them, you can use the env (short for environment) command. Per una panoramica di tutti loro, è possibile utilizzare il env (a breve per l'ambiente).
Normally, as a user, you’ll get your variables automatically when logging in to the system. Normalmente, come utente, avrai le variabili automaticamente quando la procedura di accesso 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 più importante fonte di nuove variabili è il file / etc / profile file, uno script che viene processato per ogni utente che accede al sistema. Want to add a new variable? Desidera aggiungere una nuova variabile? Add it to the bottom of the /etc/profile file to make sure it is available for all users. Aggiungerlo al fondo di / etc / profile file per assicurarsi che sia disponibile per tutti gli utenti.
Working with Bash History Lavorare con bash storia
Another useful feature of the Bash shell is the history feature, which remembers and lets you reuse commands you have recently used. Un'altra caratteristica utile di una shell Bash è la storia caratteristica, che ricorda e ti consente di riutilizzare i comandi usati recentemente. By default, the last 1,000 commands are remembered. Per impostazione predefinita, gli ultimi 1000 comandi sono ricordato. This feature is useful for sessions beyond even the current one. Questa funzione è utile per le sessioni, anche al di là di quello attuale. 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 file, che prende il nome. Bash_history, viene creato nella directory home di ogni utente, e questo file registra gli ultimi 1000 comandi che l'utente ha inserito. You can see an overview of these commands by typing history at the Bash prompt. È possibile visualizzare una panoramica di questi comandi digitando storia presso la Bash prompt dei comandi.
This is where the history feature becomes especially useful because you can reissue any command from this list without typing it all over again. È qui che la storia diventa caratteristica particolarmente utile perchè si possono emettere nuovamente qualsiasi comando di questo elenco è senza digitare una seconda volta. If you want to run any of the listed (and numbered) commands again, simply type its number preceded by an exclamation mark. Se si desidera eseguire uno dei elencati (e numerati) comandi, è sufficiente digitare il suo numero preceduto da un punto esclamativo. In this example, typing !5 would run aptitude show xen-source-2.6.16 again. In questo esempio, digitando! 5 sarebbe 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. Oltre alla storia di comando, è possibile anche utilizzare il su / giù tasti freccia, pagina su / giù chiavi, e Ctrl + p / Ctrl + N per sfogliare la storia.
A user can also erase his or her history by using the history command. Un utente può anche cancellare la sua storia utilizzando il comando storia. The most important option offered by this Bash internal command is the option -c, which clears the history list for that user. La più importante possibilità offerte da questo comando interno Bash è l'opzione-c, che cancella la storia elenco per l'utente. This is especially useful because everything that a user types at the command line—such as passwords—is recorded. Ciò è particolarmente utile perché tutto ciò che un utente digita alla linea di comando-come ad esempio le password-viene registrato. 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. Utilizzare in modo storia-c per assicurarsi che la storia viene cancellata se si preferisce non hanno altri sapendo ciò che le sono stati fino a. Once using this option, however, you can’t use the arrow up key to access previous commands, because those are all erased. Una volta usando questa opzione, tuttavia, non è possibile utilizzare il tasto freccia per accedere a comandi precedenti, perché quelli sono tutti cancellati. 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. Perché tutto si entra dalla riga di comando viene salvato, raccomando mai digitando uno di testo normale password in primo luogo, anche se si è regolarmente cancellare la storia. The commands that do require you to enter a password will prompt you anyway if you don't enter one right away. I comandi che richiedono l'immissione di una password vi verrà chiesto comunque se non si entra in una subito.
Source of Information : Apress Beginning Ubuntu Server Administration Fonte delle informazioni: Apress inizio di amministrazione del server Ubuntu
Written by magakos. Scritto da magakos. Read more great feeds at is source Per saperne di più grande al feed è fonte WEBSITE SITO WEB
no comments nessun commento . .
Read more articles on Per saperne di più articoli su Ubuntu Linux Ubuntu Linux and e otherSoftware otherSoftware . .
- [+] Digg [+] Digg : Feature this article : Feature questo articolo
- [+] Del.icio.us [+] Del.icio.us : Bookmark this article : Bookmark questo articolo
- [+] Furl [+] Furl : Bookmark this article : Bookmark questo articolo















