pwd
Print Working Directorycd
Change Directoryls
list all the content of a directory
-
sudo
super user do -
using
sudo
: having super user privilege for this one command -
sudo !!
mean run the previous command as sudo -
su
switch user -
sudo su
change into the root account
-
apt-get
program to install application -
sudo apt-get install package-name
to install a package available inside ubuntu repository -
sudo apt-get remove package-name
uninstall installed package -
apt-cache search name
for searching apt packages from the internet repositories on a Ubuntu or Debian based systems. -
apt-cache policy name
it will show whether the package is installed, which version is available from which repository and its priority. -
sudo dpkg -i package-name
install a local .deb package
-
sudo apt-get update
only updates the package list with the latest available versions, however, it does not install or upgrade the package. -
sudo apt-get upgrade
install the latest versions of all the previously installed packages on your system. This command only upgrades the packages which have a new release available as stated in the sources.list file in the “/etc/apt” folder. -
sudo apt-get dist-upgrade
also upgrades the packages. In addition to this, it also handles changing dependencies with the latest versions of the package. It intelligently resolves the conflict among package dependencies and tries to upgrade the most significant packages at the expense of less significant ones, if required. Unlike apt-get upgrade command, the apt-get dist-upgrade is proactive and it installs new packages or removes existing ones on its own in order to complete the upgrade.
-
sudo apt-get clean
helps to clean out the cache once you have installed the packages using apt-get install command in your system. It removes the files that are no longer required but are still residing on your system and keeping the system space. It removes the retrieved .deb installer files and clears out the /var/cache/apt/archives leaving only the files in the lock and the partial directory. -
sudo apt-get autoclean
is similar to apt-get clean, but only for the packages that you have uninstalled or those with no newer versions available. -
sudo apt-get autoremove
is used to remove packages that were automatically installed to satisfy dependencies for some package and that are no longer needed.
sudo apt-get update && sudo apt-get dist-upgrade
to upgrade all the packages in ubuntusudo apt-get autoremove && sudo apt-get clean
to remove caches and obsolete packages & dependencies
ls -l
output:
-rw-r--r-- 12 root users 12.0K Apr 8 20:51 filename.txt
|[-][-][-]- [--] [---]
| | | | | | |
| | | | | | +----------------> 7. Group
| | | | | +--------------------> 6. Owner
| | | | +--------------------------> 5. Alternate Access Method
| | | +----------------------------> 4. Others Permissions (3 chars)
| | +-------------------------------> 3. Group Permissions (3 chars)
| +----------------------------------> 2. Owner Permissions (3 chars)
+------------------------------------> 1. File Type "-" for a regular file, "d" for directory, "I" for symbolic link
chown
command allows you to change the user and/or group ownership of a given file, directory, or symbolic link
chown [OPTIONS] OWNER:GROUP FILE(s)
:
[OPTIONS]
example of useful options: -R, --recursive: operate on files and directories recursivelyOWNER
the new owner of the file(s):GROUP
the group ownership is changed to the given group.
example:
sudo chown -R mario:mario DIRECTORY-NAME
change recursively the owner and group of this directory by mario
chmod
command allows you to change the permissions on a file using either a symbolic or numeric mode or a reference file.
chmod [OPTIONS] MODE FILE(s)
-
[OPTIONS]
: -R: recursive, mean all file inside directory -
MODE
: different way to set permissions:- u: user
- g: group
- o: other
- =: set the permission
- r: read
- w: write
- x: execute
OR
- 4 stands for "read",
- 2 stands for "write",
- 1 stands for "execute", and
- 0 stands for "no permission."
example: rwx=4+2+1=7
example:
chmod u=rwx,g=rx,o=r myfile
change the permission ofmyfile
for owner, group and otherchmod 754 myfile
same example using numeric permission
cp [OPTIONS] SOURCE DESTINATION
-
[OPTIONS]
:
-i
To get a confirmation prompt before overwriting the files
-p
to preserve the file mode, ownership , and timestamps
-v
prints what is being done
-R
or-r
to copy folder and all file inside the folder recursively -
SOURCE
The file or the folder name that we want to copy. It can be one or multiple -
DESTINATION
destination path
Example:
cp file.txt /backup
copyfile.txt
to/backup
directorycp -R Pictures Pictures_backup
copying the directoryPictures
toPictures_backup
mv cp [OPTIONS] SOURCE DESTINATION
-
[OPTIONS]
:
-i
To get a confirmation prompt before overwriting the files
-p
to preserve the file mode, ownership , and timestamps
-v
prints what is being done
-R
or-r
to copy folder and all file inside the folder recursively
-f
Force overwriting
-n
never to overwrite any existing file
-v
Verbose output -
SOURCE
The file or the folder name that we want to copy. It can be one or multiple -
DESTINATION
destination path
example:
mv *.pdf ~/Documents
move allpdf
files from the current directory to the~/Documents
directory
rm [OPTIONS] FILE_OR_DIRECTORY
[OPTIONS]
:
-f
force delete by ignoring prompt
-v
verbose output
-d
remove empty directory
-r
remove directory and all file inside the directory recursively
-i
prompt (y/n) the user for each given file before removing it
mkdir dirname
make directory
touch filename.ext