Archive for the ‘shell’ Category
If you want to execute python scripts with Linux you need to add the shebang line: “#! /usr/bin/env python”
It must be added on top of the file.
The shebang will allow you to run the script as any other script. Among the many options to run it, assuming the script name is “script”, one is:
The file must be made executable:
> sudo chmod +x script.py
Assuming we want to print an homogenous array created with the numpy module, a script might include the module import too:
#! /usr/bin/env python import numpy as np array1 = np.array([1,2,3,4]) print(array1) print(type(array1))
It will print the following lines:
[1 2 3 4]
Running “apt-get update” ubuntu complains about missings ppa keys.
In my case I was trying to install Libre Office and the missing key was
I couldn´t find any key running:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 83FBA1751378B444
The message that I gog in the console was:
gpg: requesting key 83FBA1751378B444 from hkp server keyserver.ubuntu.com
gpgkeys: key 83FBA1751378B444 not found on keyserver
gpg: no valid OpenPGP data found.
gpg: Total number processed: 0
The solution to me was running:
and the I could finally run “apt-get update”.
If you need to convert audio files in another format you can use the tool called “soundconverter”, that you can simply install:
~$ sudo apt-get install soundconverter
Then simply run a command like:
~$ soundconverter -b -m "audio/mpeg" -s ".mp3" /home/laura/cd-wav/*.wav
“-b” stands for batch type
“-m” to specify the mime format.
“-s” to specify the suffix
And move them into another folder eventually:
~$ mv /home/laura/cd-irene/*.mp3 /home/laura/cd-wav.
For more info check the official wiki pages:
You can ping instances that are in the same security group by connecting through ssh using the internal IP:
In some posts and forum I read about adding custom ICMP rule in the security group. However it´s not what it takes, a least for me.
But the following rule will work:
Type: All ICMP
Port range: 0 – 65535
Source: Anywhere – 0.0.0.0/0
After doing this you will be able to ping other instances. You should see something like:
PING 10.0.0.15 (10.0.0.15): 56 data bytes 64 bytes from 10.0.0.14: icmp_seq=1 ttl=64 time=3.9 ms 64 bytes from 10.0.0.14: icmp_seq=2 ttl=64 time=3.9 ms 64 bytes from 10.0.0.14: icmp_seq=3 ttl=64 time=10.6 ms 64 bytes from 10.0.0.14: icmp_seq=4 ttl=64 time=40.6 ms 64 bytes from 10.0.0.14: icmp_seq=5 ttl=64 time=3.8 ms 64 bytes from 10.0.0.14: icmp_seq=6 ttl=64 time=5.3 ms 64 bytes from 10.0.0.14: icmp_seq=7 ttl=64 time=6.5 ms 64 bytes from 10.0.0.14: icmp_seq=8 ttl=64 time=3.5 ms 64 bytes from 10.0.0.14: icmp_seq=9 ttl=64 time=21.0 ms 64 bytes from 10.0.0.14: icmp_seq=10 ttl=64 time=3.5 ms 64 bytes from 10.0.0.14: icmp_seq=11 ttl=64 time=3.5 ms 64 bytes from 10.0.0.14: icmp_seq=12 ttl=64 time=59.7 ms 64 bytes from 10.0.0.14: icmp_seq=13 ttl=64 time=3.5 ms 64 bytes from 10.0.0.14: icmp_seq=14 ttl=64 time=3.5 ms 64 bytes from 10.0.0.14: icmp_seq=15 ttl=64 time=4.8 ms 64 bytes from 10.0.0.14: icmp_seq=16 ttl=64 time=3.1 ms 64 bytes from 10.0.0.14: icmp_seq=17 ttl=64 time=3.1 ms 64 bytes from 10.0.0.14: icmp_seq=18 ttl=64 time=3.0 ms 64 bytes from 10.0.0.14: icmp_seq=19 ttl=64 time=3.1 ms --- 10.0.0.14 ping statistics --- 20 packets transmitted, 19 packets received, 5% packet loss round-trip min/avg/max = 3.0/9.9/59.7 ms
Launching sudo apt-get update you might get the NO_PUBKEY issue. Something like:
W: GPG-Fehler: http://ppa.launchpad.net trusty Release: Die folgenden Signaturen konnten nicht überprüft werden, weil ihr öffentlicher Schlüssel nicht verfügbar ist: NO_PUBKEY EFD5FA852F20733F
Well it´s very simple. Just execute the following (specifying the missing public key):
[email protected]:~$ sudo apt-key adv --keyserver.ubuntu.com --recv-keys EFD5FA852F20733F
And then run sudo apt-get update again. The error will disappear.
This tutorial will allow you to upload your project on the github repository.
I am a linux fan but I have to work with Microsoft Windows. Git is integrated in the Eclipse IDE, but I want to learn to use it by command line, to learn the commands in a better way.
Reality is a bit tougher on the shell. I know about setting SSH keys on Linux. I have already blogged about it on this site, but I have decided to use the Github software provided for Windows.
The steps are the following:
1) install git to run the commands by shell. You can get the installer for Windows at: https://code.google.com/p/msysgit/downloads/list?q=full+installer+official+git
2) download and install github client, that you can find at https://help.github.com/articles/set-up-git
3) run the Github client and login with your github account credentials. The software will create a .ssh folder with your rsa git keys automatically, so you won´t have to worry about passwords and keys. Just use the github software and the provided shell.
5) clone the project locally (Github client,figure 2).
6) click on the project name in github and openshell by clicking on “tools and options>open shell here” (Github client, figure 3).
7) Navigate on the shell to your project on your desktop. For example:
You can now work on the github shell directly.
8) Run the command “
git init” to inizialize a local repository for the hb_project and check the status with “
9) Run the command “
*” or “
git add .” to tell git to commit all the files and directories in the project folder
10) Commit all the added files, adding a message running:
git commit -m "Add all content"
You can check your last activity with the “
git log” command
11) Add a new remote repository of your project:
git remote add origin [email protected]:lauraliparulo/https://github.com/laurliparulo/Hibernate_Demo.git
12) If the created repository contains file that are not on the local master run:
git merge origin/master
13) The you can finally push your project to the repository with the following command:
git push origin master
You should see the project on the github site. It takes some time to see the changes on your github client locally…
You can also manage your git project by running “
", which will open a Python revision browser.
Lately I’ve purchased a virtual private server hosting (VPS) to deploy my liferay portal. I’ve been assigned a different port number… and I needed to understand the steps to make a ssh connection.
After some hours surfing the web and making experiment, I could make it. So now I’m posting this litte tutorial, for those that want to work by the linux shell B)
Firt of all you need to generate a public and private keys with a cryptographic algorithm:
ssh-keygen -t dsa
I’ve chosen the DSA (digital signature algorithm), but you can choose RSA, etc.
After entering the ssh-keygen command on the shell, under the folder
~/.ssh/ you will find the following files: id_dsa, id_dsa.pub, authorized_keys and known_hosts files.
Make sure that you have all the permissions on the folder and that you’re the only one that can read and write the authorized_keys file:
sudo chmod 600 ~/.ssh/authorized_keys
The system will add your host to the lists of the “known hosts”, when you try to login to the remote server for the first time.
Once your keys have been generated, you need to copy the public key in the “authorized_keys” file:
cp ~/.ssh/id_dsa.pub ~/.ssh/authorized_keys
Then you need to send your public key to the server. Let’s assume that our ssh port number is 12345:
scp -P 12345 ~/.ssh/id_dsa.pub [email protected]:~/.ssh/authorized_keys
The shell will ask you a password:
[email protected]'s password: user's passowrd
Now that you’ve sent your public key to the server you can connect:
ssh -p 12345 [email protected]
After this command you’ll be asked your passphrase password (that you set when you generate the public key),
so you can be authenticated with your private key.
That’s it! 😎
To practise for the LPIC 101 I’ve decided to make a new ext4 file system on a pen drive.
Login as root.
To list all partition on all devices use the following command:
$ fdisk -l
Then format the usb device with the ext4 filesystem.
$ mkfs.ext4 -L usb_laura /dev/sdb1