Linux tricks
Σάββατο 29 Αυγούστου 2020
Τρίτη 20 Ιανουαρίου 2015
GridBagConstrains
Not Linux, but Java, but since I was working on Java and found a nice article I post the link.
http://blue-walrus.com/2011/12/gridbaglayout-tutorial/
http://blue-walrus.com/2011/12/gridbaglayout-tutorial/
Πέμπτη 9 Οκτωβρίου 2014
How to find out your extrernal IP from Linux
This question has troubled me as I want to create a script which will email me when my router address change. So since I always have a computer on, I thought that I could check the external IP and send me an email :)
The solution for the IP is found here
The command is:
Cya!
The solution for the IP is found here
The command is:
curl -s checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'
When I create (maybe after many months) the whole solution for the idea, I'll post it here.Cya!
Πέμπτη 24 Ιουλίου 2014
Bash, Vim, Nodepad++, Eclipse Autocomplete!
Hello
I would like to share with you some autocomplete keyboard
shortcuts which will make your life easier and make type faster, or much
faster!
Bash:
If you want to re-type a command you had previously typed, I
guess you usually search it with history.
Instead you can just start typing and press “Page Up”
.
This will autocomplete your typing to what you typed
earlier!
Vi:
Vi is an amazing editor if you can use it correctly.
In vi if you have a script and you want to type a variable
of function which exists in you script you just have to start typing the first
letters and they (in insert mode) press Ctrl+n
This brings you a list of all the available variables, and
you can use the arrow buttons to select what you want!
Nodepad ++:
Just as in VI, just start typing and press Ctrl+’Enter’.
This again will bring up a list of all available
autocomplete possibilities.
Eclipse:
start typing and press Ctrl+Space
Enjoy the new way of typing and share with others!
Τετάρτη 2 Απριλίου 2014
Changing the blue color on black background for putty and vim
You might have faced this but having blue letters on black backrgound, is one of the worst combination, and it is the default for putty (for directories) and vim (for the comments) !
So the solution is here:
add this line in your profile to make ls look much better:
LS_COLORS='di=0;36' ; export LS_COLORS
create a .vimrc
and just add this:
:colorscheme desert
You are done!
So the solution is here:
add this line in your profile to make ls look much better:
LS_COLORS='di=0;36' ; export LS_COLORS
create a .vimrc
and just add this:
:colorscheme desert
You are done!
Παρασκευή 7 Μαρτίου 2014
Extract a number of lines from the middle of a text file
I had this issue many times and maybe you did too.
So I would like to share what I found.
Say you have a text file
file.txt:
line 1
line 2
line 3
line 4
line 5
so you want to take only the important lines 2 to 4 so what you do?
simple:
cat file.txt |sed -n '2,4p'
line 2
line 3
line 4
---------
You are done!!
So I would like to share what I found.
Say you have a text file
file.txt:
line 1
line 2
line 3
line 4
line 5
so you want to take only the important lines 2 to 4 so what you do?
simple:
cat file.txt |sed -n '2,4p'
line 2
line 3
line 4
---------
You are done!!
Παρασκευή 7 Φεβρουαρίου 2014
How to connect with Putty ssh client to a Linux ssh server without password!
Hello my friends,
for some time I wanted to connect directly with my Linux machines without the need of typing all the time the username/password.
So I found some time to spent on this and found the way through a bit of searching on the internet.Install ssh server on linux
First let's suppose you use Ubuntu 12.04 LTS which is very common, so you need to install ssh server on this.Follow the instructions on this link
https://help.ubuntu.com/community/SSH/OpenSSH/Configuring
Your Ubuntu should be ready to accept ssh connections!
Install putty
Now download Putty for windows (or the host you are using) if you don't already have it fromhttp://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
I used for this tutorial the Windows Installer.
Now that you are set try login with putty to your account, to be sure you can login.
It should be similar to this:
Generate the Private and Public keys (puTTYgen)
now run puTTYgenpic 2
generate the keyPair, move your mouse in the blanc area you see.
pic 3
Save your keys, but make sure you do not use a Password!!! But ok, if you want to use a password you just have to use Pagent which will communicate with putty when there is a need to use the password and you'll be ok again. I'll describe what you do if you want password later.
Save the public key on the Linux server
First you have to edit the sshd_config of you server
so just
sudo vi /etc/ssh/sshd_config
Make sure the line which describes where the authorized keys are saved is not commented out!
If it is, just remove the # to look like screenshot below
Now mkdir .ssh if you don't have it
then
vi .ssh/authorized_keys
Now copy the key which was created earlier, and paste it in the authorized_keys file.
Save and exit ( esc :wq enter)
Create a putty session to connect without password!
Now you have everything set to connect without password!
Open putty and type the hostname or IP address of you Linux machine.
On Connection->Data , make sure you type in the Auto-login username. For my case it is kostas.
On Connection->SSH->Auth browse for the private key you previously saved.
Load it and you should see something similar.
Now go back to the first screen
Session
and save the session.
Now press "Open" and you will be connected without having to type a username/password!
In case you want to use password to protect private key
You will have to just save the key with password, and then you just use Pagent.
When you run Pagent you just right-click the mouse on the icon on the taskbar, and you select "View Keys".
Then you just press "add key" and you select your password saved private key. The agent will ask for the password. You are done!
When you try to connect with Putty, putty will communicate with Pagent and will use the key from there without you having to use the password.
Εγγραφή σε:
Αναρτήσεις (Atom)