You are on page 1of 4

What should I do when I don’t know/remember a command?

One good way to memorize or remember Linux commands it’s consulting the history file that lists all
the past commands. /home/[username]/.bash_history or just type “history”.

Another option is “Apropos” command. This one help you to find the right command to use
searching through the description. It’s necessary to pay attention and try to use key work. Using the
“-a” flag between words helps to get more flexible results.

“man” command show you all the details about a command, including the syntax and flag to use
with.

Package Management

Installing, updating or removing software on Linux

In Ubuntu’s package manager we use “apt” command. Usually with that you have the “install”,
“update” or “remove” options to include.

Basic commands

pwd – Show the currently directory

ls – List the files in the actual folder

ls \home – List the files in the path

ls -l -a \home – List hidden and system files in the in

history – list of all used commands before

mkdir – my_new_folder or ‘my new folder’ you the name has spacesapro

sudo + command – execute an specific command using a superuser privilege

sudo su –[with no value, change to root user directly] - change for root user. After that use “exit” or
the command below.

su –[username] – Changing actual user

passwd [username] – Changing the user password. The -e flag force the user to change the
password.

useradd/del [username] – Creating or removing a user

touch – Creating a file

cat – Showing the file content

ls -l test_file – Showing the author of a file:

-rwxr--r-- 1 student student 0 Mar 22 03:58 test_file – File or directory – Owner – Group – All other
users. Read (r - 4), write (w - 2), execute (x - 1) and disable (-).

chmod u+x / u-x [filename] – Changing the file permission. There are two ways of changing a file
permission. The firs one you can use a combination of who and which permission you are going to
add or remove. It’s possible to change just one or more. The second way is changing numerically.
When you change numerically you have to set the three permission at the same time. The owner (u),
the group (g) and other users (o).

chown [username] [filename] – Changing the owner of a file.

sudo dpkg -i atom-amd64.deb – Installing a package

sudo dpkg -r atom-amd64.deb – Removing a package

dpgk -l | grep atom – Listing all the packages that have the search terms in the name

7z e file.tar – Extracting the files from a .tar file.

apt install/remove – Installing/Removing a package

apt update - update list of available packages (Must always use before any installation)

apt upgrade - upgrade the system by installing/upgrading packages

apt full upgrade – Updating the operating system

uname -r – Used to identify the actual operating system version

Lpadmin – Printer administrator command

parted -l – List all the disks you have connected to your computer

parted /dev/sdb – Initiate the parted tool. Inside this tool it’s possible to run mor commands

mklabel gpt – Setting a disk label

mkparty primary ext4 1Mib 5Gib - Creating a partition defining size, kind and file system.

mkfs -t ext4 /dev/sdb1 – Formatting the disk (Outside the parted tool)

mount/dev/sdb1 /folder_where_mount/ - Mount a disk

umount /folder_where_mount/ or /dev/sdb1/ - Unmount a disk

blkid – Find out the UUID of a device

fsck – IMPORTANT! Before use this command make sure the file system is unmounted. There’s a high
chance to damage a mounted partition.

ps -x - Showing all the process are running on your system.


PPID – Process ID
TTL – Terminal associated to this process.
STAT – Process status: Running (R), Stopped (T) and Interruptible sleep (S).
TIME – Total CPU time the process is running.
Command – Name of the command is running.

Ps -ef – Used to get all the process, even for other users showing full details about them.
UID – The username who launched the process.
PID – Process ID
PPID – Parent ID
C – Number of children process that this process has.
STIME – The star time of this process
TTY – Terminal associated with the process
TIME – Total CPU time the process is taken up
CMD – Name of the command they are running.

ps -ef | grep chrome – Showing all the details about chrome process.

ls -l /proc – Show all the file/process inside proc folder

cat /proc/1805 – Show more information about a specific process.

ctrl + c – Combination used to send sig.init (send process) signal through the keyboard.

kill – Without any flag this command sends a SIGTERM. Is used to terminate a process giving some
time to clean up the resources it was using. This time is import to minimize a file corruption.

kill -KILL – This flag sends a SIGKILL. You use that to kill a process without giving time to clean up. This
could be more harm to the files than good.

kill -SIGTSTP – It sends a SIGTSTP command and put the process in a suspended state.

top – Show you the top process that are using the most resources on your machine, total tasks, CPU
usage, memory usage and more.

Uptime – How long is your system running, current time, how many users are logged on and the load
average.

lsof – Used to list open files and what process are using it. This could help when you are trying to
eject a USB drive but the system shows up a message that your device or resource are busy.

scp /home/cindy/Desktop/myfile.txt cindy@104.131.122.215 – (Secure copy) Used to copy files


between computers on a network.
Important files or directories

/etc/group – File where it’s possible to view all the group members

sudo:x:27:cindy – group name – group password – group id – list of users in the group

/etc/password – File where it’s possible to view all the users on the machine

/etc/shadow – File where the user password are scrambled and stored.

/etc/apt/sources.list – Package repository file

/dev (usb – sda - usbhid – List all the physic and logical devices on the computer. Each device is a file.
The most common device types are Character devices and block devices. Character is like a keyboard
or mouse and block is USB drives, hard drives or CDROMs.
When you plug a device one Kernel module is created extending the kernel functionalities without
actually touching it. If you need to update a driver you have to install a kernel module the same way
you install a software.

/etc/fstab – File where disks should be mounted automatically when the operate system starts.

/proc – Directory where all the process are listed

/var/log

You might also like