Bash tips II
RETYPING A COMMAND YOU TYPED SEVERAL LINES BEFORE
Sometimes you have to type a command you typed before, but you don't want to write it again, or don't remember exactly what you wrote on your command prompt.
Solution is easy, we are gonna use reverse search!
Press the keys: ctrl+r
and then type part of the command you want to retype.
NOTE:It is not necessary to write the beginning of the command, you can write whatever part you want for reverse search.
If reverse search has found a command but it is not the one you were searching for, type ctrl+r again till you find it, or write a better part of the command at search time.
Now we have found the command, we have two options:
- pressing enter, the command will be executed
- pressing tab key we will be able to edit this command at the bash prompt prior to its execution.
CHANGING INTO ANOTHER DIRECTORY but memorizing where we are now in order to return later easily
This is useful if you have long weird named paths.
We are now located at foo directory: :/foo$pwd
/foo
We want to change into bar directory, instead of using cd command we use pushd:/foo$pushd /bar
Now we are in /bar directory::/bar$pwd
/bar
In order to return to prior foo directory we only have to run popd command.:/bar$popd
:foo$pwd
/foo
CHECKING FOR BAD BLOCKS IN A PARTITION
Sometimes we want to check the blocks of a hard disk we have just bought, or whatever...
We have two options:
- First time, when creating the filesystem with '-c' option
e.g:mkefs.ext3 -c -b 4096 -L foo /dev/sdb2
- If the filesystem at this partition has been already created we can use badblocks command.
NOTE: Read carefully badblocks man page,$man badblocks
before doing anything potentially harmfull.
e.g:sudo badblocks -v /dev/sdb2
0 comentarios:
Post a Comment