Friday, October 26, 2018

Useful Linux command line for Ubuntu and Debian

Change the Root Password

1. sudo passwd

Note that you must type in the login password on the second line before you can type in a new password for the root and then confirm it on the last line. For security purposes, the password will not show up as you type it so make sure you type it correctly.

Now you can enter root using the su command (see below).

After you execute the su command, type in the password you made earlier and you should now be in root.

Search and Install Software

1. apt-cache search "description of the program" 

Example: apt-cache search chrome browser

Once you found the software you want you can execute the command below to install the software from the repository.

2. apt-get install chromium-browser

Note that you must be in root for this to work. If you are not in root just add sudo before apt-get then type in your root password and press Enter in order to start the installation install.

Example: sudo apt-get install chromium-browser

When it asked do you want to continue type in Y and press Enter to continue installing. 

Uninstall a Program

1. apt-get remove "the name of the installed program"

Example: apt-get remove chromium-browser

Type in Y and press Enter to remove the program.

Update Ubuntu/Debian

1. apt-get update

2. apt-get dist-upgrade

3. Type in Y and press Enter

How to install a .deb file

1. Navigate to where you download the file using the cd command.

Example: I downloaded a dropbox.deb file to my Desktop so I would type in 

cd Desktop and press Enter to change my current directory to my Desktop 

Now type in dpkg -i "package name.deb" and press Enter

Example: dpkg -i dropbox.deb and press Enter

For this example to run dropbox after the installation simply run the command dropbox start -i 

Fix Broken Installed Program

1. apt --fix-broken install

2. Type in Y and press Enter to run the fix

Note that sometimes you have to run this command first before you can run the dpkg -i command to install a program. 

Adding Github Repo To Your Distro

1. apt-get install git

2. Type in Y and press Enter to install Github repo. 

All Other Commands

To view a file's content - cat nnguyen14.txt

To make a new directory - mkdir nnguyen14

To move a file - mv file1 file2

To move multiple items in one directory - mv file1, file2, file3, directory

Give Read, Write and Execute permission - chmod 777

To change or update file access permissions - chmod +x

To clear the terminal - clear

Compare two files byte by byte - cmp file1 file2

Compare two files line by line - comm file1 file2

Assign IP address to an interface - 
sudo ip addr add dev eth0

To show all open ports - netstat -a | more


Post a Comment