Tag: Debian

Create A Python 3 Environment With virtualenv

Update: If you’re already using Python >=3.3 then there’s is already a package called venv which you can use to create you’re virtual environment with just:

python3 -m venv myennv

virtualenv is very useful in developing Python because you can create your project’s own environment without polluting the or messing with the global or your other projects Python environment.

First make sure that you have already installed virtualenv and pip for Python 3.

$ sudo apt-get install python3-pip 
$ sudo pip3 install virtualenv

Continue reading

Setting Up A Linux, Nginx, MySQL & PHP (LEMP) Stack On Debian 7

This will be a tutorial for setting up your own LEMP stack on Debian 7 Wheezy. This might be also used for installing one on Ubuntu but is not guaranteed.

LEMP Stack?

LEMP is almost the same with a LAMP stack but the Web server part is replaced with Nginx. LEMP is an acronym for a software bundle of Linux, Nginx(for E), MySQL and PHP. Sometimes any of this softwares gets replaced like MySQL can sometimes be replaced with MariaDB and PHP either Perl or Python. Continue reading

Setting Up A Linux, Apache, MySQL & PHP (LAMP) Stack On Debian 7

This will be a tutorial for setting up your own LAMP stack on Debian 7 Wheezy but this might also work for Ubuntu but is not guaranted.

What Is LAMP?

LAMP is an acronym for a software bundle that is Linux, Apache, MySQL & PHP. There are already available installer for this software stack like XAMPP which can be easily installed but if you want to setup your own LAMP stack using Debian aptitude then please read on. Continue reading

Unblock IP From fail2ban SSH

Okay, Ive done this sometimes where I typed in my password hastily and ended entering it incorrectly mutiple times which results to my IP being ban by fail2ban. To unban your IP you need to either wait for the ban time you set to expire or if you cant you will need to access your server using a different IP address.

Once you have gained access to your server type this in:

iptables -L -n

Search for the line where you IP is. It should be below the line of:

Chain fail2ban-ssh (1 references)

If its there then your IP is still banned from using SSH. To remove it type:

iptables -D fail2ban-SSH -s [your-ip] -j DROP

Change “[your-ip]” to your actual IP. Now check again the iptables and the entry for your IP is should now be gone and this means that you are now unban from fail2ban-ssh.

Setting Up Your First Debian/Ubuntu VPS

After you have created your first VPS, your VPS provider should give you the credentials for logging in through ssh. For Linux users you can just type into the terminal:

 ssh [user]@[your-vps-ip]

For Windows user you can download Putty an application that can be used for ssh. Now connect to your VPS through ssh. I assume you are now using the root user.

Update/Upgrade Server

Make sure that your server is updated. Type in:

apt-get update
apt-get upgrade

Change “root” Password

This part is optional, if you want to change the “root” password to something that you will be able to remember then use the below command otherwise move on to “Secure ssh”


Continue reading

Auto Enter Password For sudo Command

Normally using sudo will request the user a password after executing it but sometimes we might need to run a command with sudo from a script(bash script) or from a program. To auto enter a password for a script that will execute a sudo command you will need to do it like this in your script:

echo [password] | sudo -S echo "Sudo with auto enter of password"

Just replace the “[password]” with your actual password. Notice that we have “-S” as the option we pass for the sudo command. This option enables sudo to read the password from stdin where we have echoed our password.

Just an opinion but if you find yourself needing to auto enter a password in sudo command then maybe you should consider running it as a root user instead.

Debian/Ubuntu Handy apt Commands

When I first got on the Linux boat I only know that apt-get is a command to either install or remove a package from the system and only used the Synaptic Package Manager for searching packages. After a long time using Debian/Ubuntu I got to know some handy apt commands.

Here are the list of apt commands that I know right off the top of my head.

apt-get install [package name]

I think this is the first command that all people learned when they first tried Linux using Debian or Ubuntu. This command will install the package with the package name you entered

apt-get update

This command will update your systems record/cached packages list using the locations in your sources list.

apt-get remove [package name]

If you want to remove a specific package you can use this command.

apt-get purge [package name]

This command is the same as “remove” and will also remove its configuration files.

 apt-cache search [package name]

You can use this command if you dont know the exact package name. This will search the package in your systems cached packages and return the results so running apt-get update is advisable before you use this.

apt-get upgrade

This will update all packages that are installed in your system.

apt-get dist-upgrade

This will upgrade your system distribution to the latest one if its already available so this also perform the upgrade command

Samba Client in Ubuntu Command Line

Samba Installation

Check if Samba is installed

apt-cache policy samba

You should see something like this if it is installed:

 Installed: 2:3.4.7~dfsg-1ubuntu3.7
 Candidate: 2:3.4.7~dfsg-1ubuntu3.10

otherwise “Installed” on the top has a blank value. To install type in:

sudo apt-get install samba

After successfully installing Samba you can now connect to a shared folder on the network.


Suppose you want to connect to “” shared folder named “Public” . You just need to type:

smbclient // -user [Your_User_Name]

“-user [Your_User_Name]” argument is optional. If no “-user” indicated you will be defaulted to the default user. After pressing enter with the above command, the terminal is going to ask for your password. After that the terminal should look like this:

smb: \>

You are now successfully log-in in the server computer and ready to write to or copy from it.

Writing Files

To write a file in the server using Samba client use the command:

puts [local name]
  • [local name] is the filename of the file you want to transfer on the current directory before you connect in samba client. This can also be a filepath relative to the current directory or an absolute path.
  • is optional. If no is specified the filename of [local name] will be used.

Suppose we have a file named “test.txt”. We can transfer it by:

smb: \>puts test.txt

If we want it to be named “test2.txt” on the server. Type in:

smb: \>puts test.txt test2.txt

Make sure you have write access to the folder or else youll get an error like this “NT_STATUS_ACCESS_DENIED opening remote file ”

Copying Files

You can copy files from the server with Samba client using the command:

get  [local name]

and [local name] are the same as the the “put” command above.

To exit the Samba client just type “exit”.

© 2024 James Baltar

Theme by Anders NorenUp ↑