Showing posts with label console. Show all posts
Showing posts with label console. Show all posts

Friday, February 12, 2016

Remote control a linux desktop with ssh

To control single windows you can use X11forwarding.
ssh -X REMOTESERVER
For this to work on the server XForwarding has to be enabled.
Check /etc/ssh/sshd_config and make sure X11Forwarding yes is present.

That's it. You can now start graphical applications on the server and they show up on your client.



To control the whole desktop you can use x11vnc (over ssh).

First make sure x11vnc and sshd are installed on the server.

On the client:
ssh -C -t -L 5900:localhost:5900 REMOTESERVER 'x11vnc -localhost -nap -wait 50 -noxdamage -display :0 -forever'
This connects to the server, starts x11vnc to only allow local connections and tunnel the port back to the local (client) port 5900 while compressing the data (-C) to speed it all up. This way only you can connect to the remote X11 session by using a vncviewer of your choice.
vncviewer -encodings "copyrect tight zrle hextile" localhost:0

That's it.

Monday, April 28, 2014

Simple socks proxy with ssh

SSH can be used to create a simple socks proxy.

Just establish a connection from your local machine to an other computer with a running ssh server:
ssh -D 9292 user@host
 After that, setup your browser to use the local ssh redirect to connect to the internet.


That's all, you can check your IP address with a service like: http://geoiptool.com/ now.


Wednesday, August 15, 2012

vim settings / tricks i use


Here are some settings i personally use.
I will extend this post as soon as discover more.

/etc/vimrc
syntax on (syntax highlighting)
set number (line numbers)
set keywordprg=perldoc\ -f (shift-k opens perldoc for item under cursor )

to be continued

Saturday, August 11, 2012

Extended bash tab completion

Just install the package "bash-completion" in archlinux und you will get extended tab completion for the following programs: http://wklej.org/id/808581

*edit: Make sure  "/etc/bash.bashrc" is up-to-date otherwise it may not work.

Even tab completion for rsync and scp remote files structures works now.

Monday, July 30, 2012

Bash prompt shortener

Add this to your ~/.bashrc
# Bash shortener
_PS1 ()
{
    local PRE= NAME="$1" LENGTH="$2";
    [[ "$NAME" != "${NAME#$HOME/}" || -z "${NAME#$HOME}" ]] &&
        PRE+='~' NAME="${NAME#$HOME}" LENGTH=$[LENGTH-1];
    ((${#NAME}>$LENGTH)) && NAME="/...${NAME:$[${#NAME}-LENGTH+4]}";
    echo "$PRE$NAME"
}
PS1=' \[\e[0m\]\u\[\e[0;32m\]@\[\e[0m\]\h \[\e[0;32m\]$(_PS1 "$PWD" 30) \[\e[0m\]$ '
It will shorten the path in your bash prompt to 30 chars.

Saturday, January 7, 2012

Start applications with the default app from console

Its as simple as. Add this to your ~/.bashrc
alias open='nohup xdg-open >/dev/null 2>&1'
 Now you can start, for example a textfile, like this "open textfile.txt". Because of nohop in the alias you can even close the console session and the text editor stays open.

Thursday, November 17, 2011

Increase sudo timeout

There are two relevant values:

passwd_timeout  Number of minutes before the sudo password prompt times out, or 0 for no timeout.  The timeout may include a fractional component if minute granularity is insufficient, for example 2.5.  The default is 5.
timestamp_timeout Number of minutes that can elapse before sudo will ask for a passwd again.  The timeout may include a fractional component if minute granularity is insufficient, for example 2.5.  The default is 5.  Set this to 0 to always prompt for a password.  If set to a value less than 0 the user's timestamp will never expire.  This can be used to allow users to create or delete their own timestamps via sudo -v and sudo -k respectively.

I find i quit annoying when the prompt times out or you have to type in the password to often.

This are my values:
Defaults timestamp_timeout=30
Defaults passwd_timeout=0
Add them to your sudo conf with visudo.

Tuesday, September 13, 2011

Sync bash history between sessions on the fly

If you work with more then one bash terminal at a time, it can be annoying that the bash history is only available in the other session after you closed the terminal (default bash behavior).

You can fix it by adding this to your .bashrc

shopt -s histappend
export PROMPT_COMMAND="history -n; history -a"
More about it here: http://briancarper.net/blog/248/

*EDIT:
I found it confusing that the history is always synced, even in the current session. This can be confusing while working, so i changed the above a bit:

HISTSIZE=10000
HISTCONTROL=ignoreboth:ignoredups:erasedups
shopt -s cmdhist
shopt -s cdspell
shopt -s histappend
#PROMPT_COMMAND="history -n; history -a"
PROMPT_COMMAND="history -a"
Beside the obvious changes  there are some more variables changes . "HISTCONTROL=ignoreboth:ignoredups:erasedups" to prevents bash to add dups. So your .bash_history keeps clean. Beside that i have added some more fun stuff. "cdspell" fixes typos while changing directories (yeah) and HISTSIZE increases the history size to 10000 lines. 


Removing "history -n;" has the effect, that the history is still up to date when you open a new terminal but existing terminals will not get the changes immediately. You have to execute "history -n" manually if you need the changes in the current terminal.

Sunday, February 6, 2011

Resetting screen resolution with xrandr

If a game or an other application messed up you resolution you can easiely reset it by executing:

$ xrandr -s 0

Saturday, November 20, 2010

Sunday, October 24, 2010

Wednesday, September 15, 2010

Monitoring changes in filesystem

Hi there,

here a quick hint how to monitor changes in files and folders:

inotifywait --exclude 'log' -rme modify,attrib,move,close_write,create,delete,delete_self folder/

This example show everything beside changes that are made on files which have the string "log" in its name.

You can use this to see for example what config files are change by a program.

Tuesday, March 9, 2010

Rename file with special char in filename

Sometimes you cannot rename a file cause the filename contains a special char that cannot be recognized. In this case you can rename a file by its inode.

Its as simple as this:
ls -il (to get the inode)
find . -type f -inum "inode num goes here" -exec mv {} newfilename \; (find file by inode and rename it)

Saturday, August 29, 2009

Customize console resolution

You can change you console resolution:

Install "lrmi" using you paketmanager.
After that you can get a list of all available resolutions supported by your graphichardware by using: "vbetest" in a console that already uses framebuffer.

You get a list similar to this one:

[356] 1440x900 (256 color palette)
[357] 1440x900 (8:8:8)


Note the number before your preferred resolution (357 in my example).
Add 512 to this number (357 + 512 = 869).

After that open /boot/grub/menu.lst and change the line from your kernel from something like this:

kernel /boot/vmlinuz26 root=/dev/sda8 ro


to

kernel /boot/vmlinuz26 root=/dev/sda8 ro vga=869


Thats it. After restarting your system you get the new resolution in your console session.

hf