Linux Commands

Getting ssh connection error

ssh-agent bash
ssh-add ops.pem > /dev/null 2>&1

To list all users you can use:
cut -d: -f1 /etc/passwd

To add a new user you can use:
sudo adduser new_username
or
sudo useradd new_username

To remove/delete a user, first you can use:

sudo userdel username

Then you may want to delete the home directory for the deleted user account :

sudo rm -r /home/username

(Please use with caution the above command!)

To modify the username of a user:

usermod -l new_username old_username

To change the password for a user:

sudo passwd username

To change the shell for a user:

sudo chsh username

And, of course, see also: man adduser, man useradd, man userdel… and so on.

You can then add a user to the sudo group with with the command:

sudo adduser sudo

To create a new user with admin privileges in Ubuntu 12.04 and later:

adduser sudo

In Ubuntu 11.10 and earlier, use this instead:

adduser admin

To modify a existing user (12.04 and later):

sudo usermod -aG sudo

(Or for 11.10 and earlier: sudo usermod -aG admin )

-a stands for append whereas -G stands for groups. With the -a and -G flags as shown above, the sudo (or admin) group will be added to the list of groups of which the user is a member.
===========================================================================
Download

wget https://opscode-omnibus-packages.s3.amazonaws.com/ubuntu/12.04/x86_64/chef_11.10.4-1.ubuntu.12.04_amd64.deb
===========================================================================
How Do I install .deb Packages?

dpkg -i package-name-here.deb
dpkg –install package-name-here.deb
dpkg -i -R /path/to/dir/name/with/lots/of/dot-deb-files/
dpkg -i –recursive /path/to/dir/name/with/lots/of/dot-deb-files/

Where,

-i or –install : Install the package.
-R or –recursive : Recursively installed all *.deb files found at specified directories and all of its sub-directories. /path/to/dir/name/with/lots/of/dot-deb-files/ must refer to a directory instead of package-name-here.deb file name.

=====================================================================================================
How to create a compressed tar.gz file from a folder or file in Linux?
In order to create a compressed tar.gz archive from a folder/file we need to run the following tar command:

tar czf new-tar-file-name.tar.gz file-or-folder-to-archive

How to create a compressed tar.gz file from multiple files and folders in Linux?
In order to create a compressed tar.gz file from multiple files or/and folders we need to run the same tar command we used when we archived a single file/folder and to append the rest of the files/folders’ names to it.

tar -czf new-tar-file-name.tar.gz file1 file2 folder1 folder2

Here is the command explanation:

tar – the tar command.
c – create new archive.
z – compress the archive using gzip.
f – use archive file.
new-tar-file-name.tar.gz – the name of the tar.gz to create.
file-or-folder-to-archive – the name of the folder we want to archive.

How to extract a compressed tar.gz file in Linux?
tar -xzf tar-file-name.tar.gz

Here is the command explanation:

tar – the tar command.
x – extract the archive.
z – uncompress the archive using gzip.
f – use archive file.
tar-file-name.tar.gz – the name of the tar.gz to create.

The tar command will extract all the files/folders in the archive to the current directory.

How to extract a compressed tar.bz2 file in Linux?

Extracting tar.bz2 (bzip2 file) is very similar to the way you extract tar.gz file. Instead of using the -z flag you need to use the -j flag for the bzip2 format
tar -xjf tar-file-name.tar.gz

Here is the command explanation:

tar – the tar command.
x – extract the archive.
j – filter the archive through bzip2
f – use archive file.
tar-file-name.tar.gz – the name of the tar.gz to create.

The tar command will extract all the files/folders in the archive to the current directory.

Try clearing your apt repository and removing any broken packages first:

sudo apt-get update
sudo apt-get autoclean
sudo apt-get clean
sudo apt-get autoremove

If the system identifies any broken packages, forcefully remove them (replace package_name with your own):

sudo dpkg --remove -force --force-remove-reinstreq package_name

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: