- 1 Linux: about key SysRq & When Linux is buzzed.
- 2 Syntax highlighting in Vim
- 3 Change the color of MC (MidnightCommander).
- 4 Adding useful information to shell bash.
- 5 History commands bash.
- 6 Native console.
- 7 Linux-Aliases.
- 8 Linux-WEB: Download site entirely from the console
- 9 What to do if forgot your password root in linux?
Linux: about key SysRq & When Linux is buzzed.
When Linux is buzzing [it may buzz sometimes. While not as often as products of a well-known company from redmond], and the standard of a "canonical" x-reboot through Ctrl+Alt+Backspace, as well as attempts to break into the console via Ctrl + Alt + F1 no longer works, its not worth pushing in the Reset button on the system unit. - It is not worth pushing RESET button. It is better to do everything nice and neatly. Like this:
1. Hit Alt + SysRq + R (and beyond + E, I, S, U, B)
R: returns control over input devices (Keyboard / mouse)
E: save & finish all processes except init (all date is saved)
I: unsafe process finish (SIGKILL. All data is lost.
S: synchronizing and ttansfering data from cashe to HDD
U: remounting (remapping) all avaliable fs in read-mode
... Est.: Key SysRq - same as PrintScreen.
Syntax highlighting in Vim
First install an additional package:
$ zypper in vim-data
then open and edit the file
$ vi /etc/vimrc
find "syntax on" line and uncoment it.
Change the color of MC (MidnightCommander).
open and edit file
and add a section
[Colors] base_color=normal=brightgray,default:marked=yellow,default:directory=green,default:marked=yellow default:errors=red,default:marked=yellow,default:executable=brightgreen,default:marked=yellow default:link=brightblue,default:marked=yellow,default:device=brightmagenta,default:marked=yellow
I gave my the option coloring :)
Adding useful information to shell bash.
open and edit the file
and add the variable
PS1 = "\u@\t\w\$"
get this type of invitation
the current time and current directory. "\u", user), the computer name ( "\h", host), time ( "\t", time), the path to the current directory ( "\w", work directory) "\W" (showing the last element ways, that is the current directory name), "\w", the full path because "\w" has the property to provide the full path home and replace it with "~".
History commands bash.
Two other arrow keys - up and down - are also actively used, not suspecting that will use this very powerful mechanism bash - with history. All commands, the user typed, bash stores and allows you to access them later. If you want to get stories from some long-standing team, it is easier not to drive a list of stories pointers, and search using "^R" - (Ctrl+R) (reverse search). In doing so, displays a hint of special type ( "reverse-i-search"), substring search (surrounded by symbols of `and ') and the last of the teams in history, in which the substring is:
^R | (reverse-i-search)`':
i | (reverse-i-search)`i': ls i
n | (reverse-i-search)`in': info
f | (reverse-i-search)`inf': info
o | (reverse-i-search)`info': info
^R | (reverse-i-search)`info': man info
^R | (reverse-i-search)`info': info "(bash.info.bz2)Commands For History
Periodic restart commands to redraw the screen: For example, to display the contents of the directory changes:
watch -d ls -l
Creating a directory with the missing intermediate directories:
mkdir -p /tmp/dir1/dir2/dir3
And bash is convenient creating the following number of directories at one level of nesting
mkdir -p /tmp/dir1/dir2/(dir3,dir4)
This operator executes the command for each operand and this would be equivalent
mkdir -p /tmp/dir1/dir2/dir3 mkdir -p /tmp/dir1/dir2/dir4
And it can be used for any commands, such as
chmod 775 /tmp/dir1/dir2/(dir3,dir4)
Fast sending directory over SSH
An example of the way in which you can compress on the fly and then unpack the catalog sent to a remote machine over shh. like this:
tar -cjf - /dir/to/copy | ssh user@remote 'cd /where/to/ && tar -xjf -
Another convenient tool while working with the command line is alias. For frequently used command, it is usually faster to create an alias and use that instead of searching through the list of command histories (with the help of several "^R") for the command you are looking for. alias is defined in the configuration file, and the current aliases can view by issuing the command:
The output will be something similar to:
alias +='pushd .' alias -='popd' alias ..='cd ..' alias ...='cd ../..' alias beep='echo -en "\007"' alias cd..='cd ..' alias dir='ls -l' alias l='ls -alF' alias la='ls -la' alias ll='ls -l' alias ls='ls $LS_OPTIONS' alias ls-l='ls -l' alias md='mkdir -p' alias o='less' alias rd='rmdir' alias rehash='hash -r'
For instance, this means that when you enter +, the command line actually replace it by pushd .
Other than the predefined list, you may add your own alias:
By default, the alias created using this command only last for the current login session (Until the user logout / shutdown). To make alias permanent you can edit the .bashrc file in your home directory. See The alias Command for more info.
To remove aliases, use the command unalias instead.
Linux-WEB: Download site entirely from the console
Command-rocker wget default is present in any * nix-system (well, or almost any). With its help we will get our desired site. Full.
adramelech@02:38:30/$ cd /home/adramelech/websites
adramelech@02:39:34/websites$ wget -r -k -p -N -l 5 http://www.Target_SITE.net/
Description of options:
-r - Recursion
-k - converting links
-p - content pages
-N - time-stamping (On request only if you are going to refresh the page to download)
-l - the depth of links
What to do if forgot your password root in linux?
1. When booting GRUB Hit Esc and then select the line initialization kernel and edit the settings loaded kernel, adding at the end of the line:
init = /bin/bash
Hit Enter, then B
after booting write
passwd root Enter passwd root
Indeed, there can not only change the password root.