Saturday, April 23, 2016

Summary of my Telebots

echo -ne "\033[9;0]" >> /etc/issue
sudo vi /etc/apt/sources.list
sudo nano /etc/ssh/sshd_config
sudo nano /etc/ssh/ssh_config
sudo service ssh restart
sudo reload ssh
sudo apt-get install openssh-server

sudo apt-get install git
sudo git clone addressurl
sudo apt-get install python3-pip
python3 --version
pip3 install python-telegram-bot
pip3 install future
python3 -c "import telegram;print(telegram.__version__)"

sudo ssh-keygen -t rsa
sudo ssh-copy-id username@server
sudo rsync -a bot.sqlite -e "ssh -p 1234" username@server:/home/admin/Backup
echo "1234" | sudo -S rsync -a /home/username/python-telegram/bot.sqlite -e "ssh -p 1234" username@server:/home/username/Backup/??/bot-1m.sqlite


https://pypi.python.org/pypi/python-telegram-bot/1.4
https://pypi.python.org/pypi/python-telegram-bot#downloads
Newbie Guide - https://python-telegram-bot.org/
TempSend - http://tempsend.com/

Friday, April 22, 2016

rsync Tips

sudo rsync -a bot.sqlite -e "ssh -p 1234" admin@server:/home/admin/Backup

Tuesday, April 12, 2016

Python Version

Python2 is the default Python version in Ubuntu. To change to python3, you can use the following command:

alias python=python3

This will change the default version to Python3.

To revert back:

alias python=python2

Saturday, April 9, 2016

How to setup crontab ubuntu server terminal without sudo?

I won't get into how much this is a bad idea; simply put, running sudoin crontab requires your password to be stored somewhere in plaintext.
It's a bad idea.

The following is the preferred method of running administrative tasks through cron. Since you don't really need to write sudo in the crontab, if you are modifying root's crontab.

Use root's crontab

Run the following command:
sudo crontab -e
This opens up root's crontab. sudo is not necessary to run your command in this context, since it'll be invoked as root anyway.
Therefore, you would simply append the following to root's crontab.
@hourly rm somefile

Now, if you absolutely want to be unsafe and take risks with your password, the following will run your command from your own crontab, and enter your password automatically when prompted by sudo.
Again, this is not recommended.

In your own crontab, write your command like so:
@hourly echo "password" | sudo -S rm somefile
The obvious disadvantage here is that, should anyone ever access your crontab, your password will be readable in plaintext.
You shouldn't do this.
shareimprove this answer
   
I got it, thanks a lot – sayem siam Aug 9 '12 at 18:11
1 
Glad it works! Just be wary of any security holes you leave behind.. They might come back later to haunt you. – SirCharlo Aug 9 '12 at 18:15
1 
@SirCharlo Why use root's user crontab instead of the systemwide crontab /etc/crontab? – Eliah Kagan Aug 10 '12 at 3:47
1 
@Elijah why not? – SirCharlo Aug 11 '12 at 4:43
If you are putting the script from one of the cron directories (/etc/cron.*) then you don't need to use sudo as that is running as root.
If you are using crontab, then you will want to use root's crontab. This will run it as root, and also not need sudo.
sudo crontab -e
shareimprove this answer
   
I would also place the command in /etc/cron.hourly/something. That's what these directories are for. – John S Gruber Aug 23 '12 at 15:37
2 
No. You could put it in /etc/cron.SOMETHING/SCRIPT, but I wouldn't do both. Both would give roughly the same function, although using crontab you would have a bit more power over how often/when things run. – tgm4883 Aug 23 '12 at 17:40
   
I should have made clear that I meant that as an alternative. Thanks. – John S Gruber Aug 23 '12 at 17:43

Run following command in terminal
sudo visudo
Added the following line to the end of the file:
vidyadhar  ALL= NOPASSWD: /bin/rm
In the above example vidyadhar is the username and it will not ask for password if you are running rm command through vidyadhar.

How to disable blank screensaver on Ubuntu Server?

Prevent screen from turning off

You can run this command:
$ setterm -blank 0 -powerdown 0
Alternatively you can disable console blanking permanently using the following command:
# echo -ne "\033[9;0]" >> /etc/issue


Type setterm -blank 0 on any shell to disable blanking out of tty consoles.
Type sudo xset s 0 0
0 disables blanking, any value greater than 0 is the time in minutes. Default is 10.
To permanently enable this you can add this line to your ~/.bashrc config.

Friday, April 1, 2016

How to load a USB device to Ubuntu and recognize as /dev/ttyUSB*



Serial Port Setup

You need to be a member of the group that owns the serial port device connected to your rig. On Debian-based systems such as Debian GNU/Linux, Ubuntu and its derivatives (Kubuntu, Xubuntu, Lubuntu etc.) and Mint, just to name a few, this is the "dialout" group. On other systems you can determine the group you need to join with this command:
$ ls -l /dev/ttyUSB*
(If this doesn't return any files, use "ls -l /dev/ttyS*" instead.)
This should give you a list of one or more serial port devices of the form:
crw-rw---- 1 root uucp 188, 0 Jul 22 02:49 /dev/ttyUSB0
In this case the serial device is owned by user "root" and group "uucp", so you want to add yourself to the "uucp" group. In the examples below we will use "dialout" for the group we need to join.
There are several ways to add yourself to a group.
From a terminal, you can enter the following command
$ sudo adduser (username) dialout
Substitute your login name for (username)
You can check to be sure that you are now a member of the dialout group with the command:
$ groups
which should respond with the full list of groups you belong to.
There are also Graphical User Interface tools that perform the same basic function. On Lubuntu this is the "users-admin" command which is usually found on the Lubuntu menu item "System Tools | Users and groups". You can of course start that tool from the command line
$ sudo users-admin
sudo is used for all of these modifications to ensure that you have the correct read/write privilege for the files that will be changed. You must log out and log back in again for the change to take effect.

Mint distribution

Contributed by Charlie, NA5NM
  • Goto "Menu" and select "Control Center."
  • In the "Control Center" select "Users and Groups."
  • Under "Users and Groups" you will select "Manage Groups"
  • A list of all the different groups will appear so you may scroll through the list to find 'dialout' select it then press the "Add" key.
  • You must log out and log back in again for the changes to take effect.

Ubuntu Unity desktop

Contributed by Dave, WB5NHL
  • Click on "Dash Home" symbol in upper left corner of the desktop
  • Key "users" click on the "Users and Groups" icon
  • Select "Manage Groups"
  • A list of all the different groups will appear so you may scroll through the list to find 'dialout'
  • Highlight "dialout" and select "Properties"
  • If the box next to your name is checked, you are a member of the dialout group. If not, check the box!
  • You must log out and log back in again for the changes to take effect.

Korora (based on Fedora)

Contributed by John, KC5LAA
· Go to “Menu” and select “Administration” > “Users and Groups”
· Under “Edit” select “Preferences” and uncheck “Hide system users and groups”, then exit “Administration”
· Select “Groups” tab
· A list of all the different groups will appear so you may scroll through the list to find “dialout”
· Highlight “dialout” and select “Properties”
· Select “Group Users” tab
· Scroll down through the list of users to find your name.
· Make sure the box next to your name is checked.
· Select “OK” to exit the “Properties” window.
· Exit “Users and Groups” window
You must log out and log back in again for the changes to take effect.

USB->RS232 adapters

The serial drivers may need to be installed for the device to work properly. After plugging in the device, first check the hardware messages to see the device was detected:
dmesg
Torward the end of the messages, you should see this:
usb 1-1: new full speed USB device using uhci_and address 2
usb 1-1: configuration #1 chosen from 1 choice
Now, we need to figure out the device vendor number and product number to tell the usbserial driver. For this we can use lsusb. The easiest way to find the information is to first unplug the device, then run lsusb:
lsusb
You will see a summary list of your USB devices on the system, for example:
Bus 001 Device 001: ID 0000:0000
Now, plug the device back in, and run lsusb again:
lsusb
Which returns the summary list again, but now showing the new USB device:
Bus 001 Device 002: ID 4348:5523
Bus 001 Device 001: ID 0000:0000
Now, we can load up the driver for this device:
sudo modprobe usbserial vendor=0x4348 product=0x5523
Finally, check dmesg again to ensure it loaded properly.
dmesg
Near the end, you should see something like:
usbserial_generic 1-1:1.0: generic converter detected
usb 1-1: generic converter now attached to ttyUSB0
usbcore: registered new interface driver usbserial_generic
Congratulations, your link is up - in this example, the device can be used on /dev/ttyUSB0. As much fun as you had doing this, there is some chance you want to do this automatically in the future. Just add this line:
usbserial vendor=0x4348 product=0x5523
to /etc/modules with the vendor and product numbers you found. Of course you must user sudo to edit that file.

Virtualbox Ubuntu Screen Resolution Fix

sudo apt-get install virtualbox-guest-utils virtualbox-guest-x11 virtualbox-guest-dkms

Blast SMS


  • https://www.diafaan.com/reviews/use-diafaan-sms-server-with-android-phones/
  • http://b.fl7.de/2014/05/huawei-e303-sms-vulnerability-CVE-2014-2946.html
  • https://hashtips.wordpress.com/2013/04/12/send-sms-using-a-usb-modem-and-ubuntu-12-04/
  • http://www.techytalk.info/send-receive-sms-using-gsm-modem-phone-ubuntu/
  • http://www.draisberghof.de/usb_modeswitch/
  • http://stefanfrings.de/smstools/SMS_Applications.pdf (important)

:sudo apt-get install gnome-system-tools