Showing posts with label terminal. Show all posts
Showing posts with label terminal. Show all posts

Friday, 10 September 2010

Howto: Bind Keys In Nautilus To Scripts Or Other Menu Items.

I picked up this excellent tip from Webupd8.

First you should have installed Nautilus Open Terminal for an initial very useful shortcut. It adds a menu entry on the right click and in the File menu to do exactly what it says, open a terminal at the current folder you have open in the active Nautilus window. So enter the following into a terminal.

sudo apt-get install nautilus-open-terminal

If it is already installed it will just inform you of it in the text it spews, otherwise it will install it, and inform you of that too.

Open up gconf-editor from a terminal or Alt+F2 (you may also have it listed in your Applications/System Tools/ menu as Configuration Editor. Be a little bit careful in here, there is possibility of breaking stuff. Navigate in the left hand pane to Desktop/Gnome/Interface.

Change the toggle for "can_change_accels" to true/enabled. Leave the gconf-editor window open as you most likely want to disable it again after setting the keybindings you want. Be aware that you can only bind to the main Nautilus menu and not to its right click menu.

Press Alt+F2 and enter "nautilus -q" to restart Nautilus, then you may set any menu item or script to have a key bind simply by opening the Nautilus main menu and then pressing the key bind that would like to set it as while hovering over the item. For instance I hovered over Open Terminal and I have set to F4, I have also added bindings to other scripts I use fairly frequently.

I would suggest disabling the "can_change_accels" to false again to prevent accidental overwriting of key bindings, thats entirely up to you though, and be aware of what key binds you set of course, binding ctrl+c to close/quit nautilus is going to cause problems ;)

Sunday, 18 October 2009

Howto: Sync Bash History Between Terminals

Do you want to be able to use the history from another terminal quickly and simply in a new terminal, or to be able to use any one of the terminals on your desktops to continue working with a current history?

Me too :]

This is a very easy tweak and makes a lot of sense to most people. So we need to edit the file ~/.bashrc

gedit ~/.bashrc

At the bottom paste in the following:

shopt -s histappend
PROMPT_COMMAND="history -n; history -a"
unset HISTFILESIZE
HISTSIZE=2000


Unsetting HISTFILESIZE just gets rid of the filesize limitation, and we rely on HISTSIZE which allows 2000 lines in the file, both normally default to 500.

PROMPT_COMMAND tells bash to reload history and append to history each time it draws the prompt in the terminal.

The only thing to note is if you jump from one terminal to another and wish to recall the last history line from the former terminal, press enter once with a blank line, this causes bash to draw the prompt and sync, if you only just opened the second terminal then you don't have to. The sync only occurs when the prompt is drawn, nothing else to note.

Tuesday, 25 August 2009

Make Pasword file Immutable - A Security tip

You can add a extra layer of protection to your machine, or in my case help to prevent wannabe haxx0r brothers at the parents house from changing to extremely short passwords with a little trick that not many are aware of.

What happened to me was my brother managed to shoulder surf the admin account on my parents PC, I normally update their PC by SSH from home, but I was around there visiting and mum had described a problem so I was fixing it while we chatted, my brother was lurking around and managed to shoulder read my 12 digit alpha numeric password (have to give the guy a bit of credit there, sadly)

Anyway I became aware that files on the admin account had incorrect accessed times afterwards and then looked deeper and found that someone had been in on the account and had changed my brothers password on his account from a sensible 10 digit alphanumeric (which was dead simple to bang in with two fingers as the digits were paired on the keyboard) into a rather less safe two letter password. He claimed that a friend had helped him break into my account as "you aren't the only one that knows linux", as if I ever imagined that I was some guru, I'm a self confessed learner still! As we "discussed" this further he came clean that he had simply watched me enter the password rather than "hacked" in.

Anyway lets get onto the crux of this, after setting your passwords open a terminal and enter:
chattr +i /etc/shadow

This will make the file immutable, which means that it cannot be deleted or renamed, no symlink can be made to this file and no data can be written to the file. The immutable flag must be cleared before passwords can be changed, if you try to do so without clearing it then it will appear to change the password, but in fact it would not write to the file, without error. Meaning the new password would never be written and the old password would continue being the active one.

If a fairly knowledgeable user tries to dig into why it won't write and they try:
$ ls -l /etc/shadow
-rw-r----- 1 root shadow 1027 2009-08-25 14:37 shadow


There is nothing obviously wrong with writing to the file, to check properly you would use:
$ sudo lsattr shadow
----i------------- shadow


Here we can see the +i flag set for immutable. If we clear that with:
chattr -i /etc/shadow
The password can now be changed as normal, using sudo passwd username
and then it can be set +i again to protect it.

A little bit sneaky and just a little bit safer.

Wednesday, 12 August 2009

Enable Composite Manager in Metacity

Not every computer has the resources to run Compiz, but if you pine after some nice effects like window shadows then there is a good chance your computer is capable of running simpler effects. i use this on my Acer Aspire One, sure it can manage Compiz, but it is a little overkill on the baby netbook.

Well rejoice now as Metacity has a composite manager built in which can give you nice drop shadows as well as a window preview on alt+tab and that  pesky inactive window title-bar transparency (which I detailed how to disable last post).

Enable the composite manager in gconf-editor and navigate to the branch in apps/metacity/general

Tick the box next to the setting composite_manager and you are now hopefully enjoying drop shadows... Yay!

A quick alternative is to paste this into a terminal

gconftool-2 -s '/apps/metacity/general/compositing_manager' --type bool true

and if you need to disable it again use:

gconftool-2 -s '/apps/metacity/general/compositing_manager' --type bool false




Tuesday, 14 July 2009

Set up rxvt terminal with unicode and clickable URL's

Rxvt is a super fast unicode terminal which I have recently switched to away from Eterm for my transparent desktop terminal.

sudo apt-get install rxvt-unicode-ml

Next is to create a configuration file for it in your home folder.

touch .Xdefaults

Now paste this lot in...

URxvt*termName: rxvt

## borderless and no scrollbar
URxvt*scrollBar_right: false
URxvt*scrollBar: false
URxvt*borderLess: false

## teh transparency stuff
URxvt*inheritPixmap: true
URxvt*tintColor: white
URxvt*shading: 100

##
## These 3 lines make links clickable
##
URxvt.urlLauncher: firefox
URxvt.matcher.button: 1
URxvt.perl-ext-common: matcher,readline

## geometry and font
URxvt*geometry: 80×15
URxvt*font: xft:Terminus:pixelsize=12

## change default colors
URxvt*background: #000000
URxvt*foreground: #A8A8A8
URxvt*color0: #000000
URxvt*color1: #A80000

## URxvt*color2: #00A800
URxvt*color2: #ED254F

URxvt*color3: #A85400
## main bars in irssi
URxvt*color4: #020202
URxvt*color5: #A800A8
URxvt*color6: #00A8A8
URxvt*color7: #A8A8A8
URxvt*color8: #545054
URxvt*color9: #F85450

## Time in Irssi
URxvt*color10: #ED254F
## URxvt*color10: #50FC50

## URxvt*color11: #F2FC50
URxvt*color11: #ED254F

URxvt*color12: #5054F8

URxvt*color13: #ED254F
## URxvt*color13: #F854F8

URxvt*color14: #50FCF8
URxvt*color15: #F8FCF8

Note that some of the colours have been changed to coordinate with my current desktop theme, the original colours are commented out so you can easily revert. Also the line defining the window geometry seems to have no effect, I shall look into that and correct it when I get some time and inclination. At the moment I don't mind because the default window size is fine, and the launcher I use to start the transparent terminal I use on the desktop mainly for my screen with irssi, hellanzb and mediatomb in has the geometry set on it. the launcher command is:


rxvt -g 80x15

Last job is to tell compiz to not decorate this window, this will get rid of the title bar, borders and shadow etc.

Hopefully you have installed the advanced compiz settings (ccsm), so just open that up and go to the section for window decorations
in Effects, Window Decorations.

Add the rxvt window to be excluded from shadows and decorations, and that should see you done.



Thursday, 9 July 2009

Synaptic not showing search results

Synaptic fails to show search results for packages that you know are present.

This was an annoying little problem I had on 8.10 and bless my soul if it didn't occur on my fresh clean install of 9.04, so I thought I should throw the solution up here in case I need it again, or anyone else does.

Open a terminal and issue the following command

sudo update-apt-xapian-index

It will just take a couple of minutes to rebuild the apt database, then Synaptic should work fine again.



Tuesday, 26 August 2008

rTorrent, light and fast bittorrent client.

I use two torrent clients almost every day, Transmission on my own box with a gnome desktop, and for a long time now rTorrent in a shell via SSH to a spare machine I have use of on a separate connection. Setting up rTorrent on an Ubuntu machine is what I am going to discuss here.

First step is to install the program, open a terminal and enter:

sudo apt-get install rtorrent

Or use Synaptic and search for 'rtorrent', install it. A basic config file is located /usr/share/doc/rtorrent/examples for you to tweak to your own liking, at its simplest you may want to change the download folder in it and the 'watch' folder. The watch folder is a place that rTorrent will monitor for *.torrent files coming into so it can automatically start, and when the download has completed and achieved a ratio you are happy with, you can just delete the torrent file from this folder to remove it from rTorrent. Dead simple stuff :]

cp /usr/share/doc/rtorrent/examples/rtorrent.rc ~/.rtorrent.rc

then edit this file with your prefered text editor, mine is usually nano, use gedit if you prefer a GUI editor:.

cd ~/
nano .rtorrent.rc

Now we can make the most basic of changes, first up is the download folder, look for the line:

# Default directory to save the downloaded torrents.

change the line after it to the folder you want to be your download folder and remove the # so you have something like this:

# Default directory to save the downloaded torrents.
directory = ~/torrents

This makes my download folder /torrents/ in my home, the default without editting is simply your home folder which you may be happy with.

Next lets tell it what folder to watch for torrent files. I have defined mine to be this same ~/torrents/ folder, you may prefer to leave it as your home folder. Either way find these lines just slightly down from the previous:

# Watch a directory for new torrents, and stop those that have been
# deleted.
schedule = watch_directory,5,5,load_start=~/torrents/*.torrent
schedule = untied_directory,5,5,stop_untied=

Yours will look very slightly different as I have shown how I changed mine to watch the ~/torrents/ folder. You should now save the file and close the editor, ctrl+o to save in nano if you used my prefered editor from above and don't know it, press enter to save wit hthe same name, then ctrl+x to close it.

You should now be free to start rTorrent with the command:

rtorrent

Not very impressive at first look is it, but download a torrent file to the watch folder and see rtorrent leap into action all by itself. You can adjust the upload and download speeds using the keys

a/s/dIncrease the upload throttle by 1/5/50 KB.
z/x/cDecrease the upload throttle by 1/5/50 KB.
A/S/DIncrease the download throttle by 1/5/50 KB.
Z/X/CDecrease the download throttle by 1/5/50 KB.


There are other keys to pause and resume torrents and many other facilities that you may require, for that I would point you at the User Guide page at http://libtorrent.rakshasa.no/wiki/RTorrentUserGuide


As I use this remotely I also run it inside a screen so I can safely detach from it and break the connection leaving it running on the remote machine, to do this enter in a terminal:

screen

then you will just see another command prompt on a clear terminal at which point enter:

rtorrent

rTorrent will start as normal but if you use the keys ctrl+a then d it will detach, that is it will drop you back at your original shell, leaving rtorrent running in the backgroun still. You can attach to it again with:

screen -r

You can then see rTorrent again to check your downloads or ratios. Check 'man screen' for more help on using screen, there are a *lot* of things you can do with it, and that might be a worthwhile post for me some time soon.