Avatar

Araz Gholami

Hi, I'm @arazgholami, Programmer, Blogger and Explorer.
I create things and make them better. I'm a repairer, not replacer.
I love to transform complex things to simple things.

WTF-IS: Linux Terminal

Preface: This post is a quick tutorial about a specific tool or concept. What you read below is the essential knowledge you need to quickly learn to use this tool or concept. I publish these series under the name WTF Course.

Quick Guide to Linux Terminal Commands:

Debian/Ubuntu Only:

sudo apt update | check for updates
sudo apt upgrade | upgrade packages if updates are available

sudo apt install [appname]
sudo apt remove [appname]

sudo dpkg -i file.deb

sudo apt autoclean && sudo apt autoremove | clean unnecessary packages

Basic:

sudo [command] | execute command with root privileges
use Tab for command autocompletion
Ctrl+C | stop the currently running process/command
clear | clear the terminal screen
source filename | reload a file (usually for Linux config files)
alias a="clear" | create your own command/shortcut (a = clear)
Note: Aliases must be added to ~/.bashrc for permanence (refresh with 'source ~/.bashrc')

| (pipe) | send a command's output as input to another command
> | redirect command output to a file
>> | append output to end of a file (e.g., echo alias c="clear" >> ~/.bash_aliases)
&& | execute two or more commands together (e.g., cd ~ && clear)

Commands:

pwd | show current directory

ls -lah | list all files with details

cd /path/to/directory | move to a directory
cd - | move to previous directory
cd .. | move up one directory
cd ~ | move to home directory

touch filename | create a new file
cp a location/filename | copy file to another location
mv a location/filename | move (cut/paste) file
echo STRING >> file | create a file and append a string

cat filename | display file content
cat a b > c | combine files a and b into c

mkdir | create a new directory

rm filename | remove file
rm -r directory | remove directory

locate filename | find a file
locate -i STRING | search for string in all files
find LOCATION -name NAME | search for a name in a location

grep string file | search for string in a file

du -m filename | get file size in MB

head -n 5 file | show first 5 lines of a file
tail -n 5 file | show last 5 lines of a file, add -f for real-time monitoring (also 'tailf file')

diff a b | show difference between files

zip b.zip a | compress file a into b.zip, use -r for directories
tar -cvf a.tar b | create tar archive named a from b location. More: https://www.tecmint.com/18-tar-command-examples-in-linux/

chown user file | change file owner to user
chmod 777 file | change file permissions. More: https://www.computerhope.com/unix/uchmod.htm
chmod +x filename | make file executable

top | task manager
ps ax | grep APPNAME | find process ID
kill pid | terminate process by ID
pkill appname | terminate process by name

history | list all previously used commands
which [command] | locate command executable

passwd a | change current user password to a
man [command] | display help/manual for a command
Araz Gholami · · MD · TXT
Share: https://arazgholami.com/linux-terminal

Leave a comment




Comments

Subscribe to my 📶 RSS or submit your email here and I'll send you my last articles directly to your email.
No spam. I promise.