Giter VIP home page Giter VIP logo

essential_linux_commands's Introduction

Essential_Linux_Commands

Picture

*** This repository contains some of the important often used Linux commands anyone interested in learning Linux should know. ***

1. ssh

ssh \<username>@\<serverIP>

2. ls

List all the files in the directory

ls -l gives list files with permissions
ls -al gives hidden files as well

3. pwd

Be able to print the current directory

4. cd

Changing directory

cd \<path> navigate to the respective directory
cd .. jump back directory
cd naviagate to home

5. touch

touch \<filename> create a new file
touch \<filename1> <filename2> create several files
touch \<filename>{1..10} create 10 files

6. echo

echo \<message> print the message
echo \<message> \> \<filename> Add message to the file

7. nano

nano \<filename> edit a file
To save use ctrl + X and Y and Enter to save

8. vim

vim \<filename> edit a file
Hit I to start editing When done use hit ESC and :wq

9. cat

cat \<filename> Read content of a file

10. shred

shred \<filename> Don't let anyone to read the file.

11. mkdir

mkdir \<directory name> create a new directory

12. cp

cp \<file name> \<path where to copy> Copy file to a given path mv \<file name> \<path where to move> Move file to the given path

13. rm

rm \<file name> Remove a file

14. rmdir

rmdir \<directory name> For an empty directory removal rm -r \<directory name> To remove a directory with files in it

15. ln

ln -s \<file name> <link> Can create a link to a file with -s switch for soft

16. clear

Clear the terminal

17. whoami

Tells who you are😄 (returns the username)

18. useradd

useradd \<name> Create a new user

19. sudo

sudo \<command which needs permission> Uses when asked for permission Need to enter the password for user

20. adduser

Can reverse the command useradd

21. su

su <username> Can switch user

22. exit

Exit temparary user. (can use in several occasions)

23. passwd

passwd <username> Can change the password of the user

24. apt

sudo apt update Needs to update before install sudo apt install <package> Install packages

25. finger

Needs to install finger package first

finger \<username> Can be used to inspect another user

26. man

man \<command> Can get help with things that don't know

27. whatis

whatis \<command> Faster than man command to get help

28. whereis

whereis \<command> To findout where the command is

29. wget

wget \<link> Help to get stuff from the internet (download)

30. curl

curl \<link> Help to get stuff from the internet

31. zip

zip \<zip file> <file name> Make a zip file

32. unzip

unzip <zip file name> Unzip the file

33. less

less <file name> Can read one page at a time. (substitution for cat command)

34. head

head <file name> Output only the begining of the file

35. tail

tail <file name> Output only the ending of the file

36. cmp

cmp <file1> <file2> Compare two files and check whether any differences exist.

37. diff

diff <file1> <file2> List the differences of the two files

38. sort

cat <file name> | sort The file is sorted in alphabatical order

39. find

sudo find <the directory> -name "<search key>" Find the search key sudo find <the directory> -type f -name "." Find all hidden files find <the directory> -type f -empty Finds all empty directories find <the directory> -perm /a=x Finds all executable files

40. chmod

Change the permissions of the file

chmod <permission> <file name> To change permission of the file.

Important

Here are the permission types
0 no permissions
1 can execute
2 can write
3 can write, execute
4 can read
5 can read, execute
6 can read, write
7 can read, write and execute

41. chown

chown <user> <file name> Changing owner of the file

42. ifconfig

Gives IP address of the machine

43. ip address

Returns the ip address

Note

Can also use the command grep to only return ip address of a specific interface. Ex: >ip address | grep eth0 Return only the ip address of ethernet 0.

Important

If only the ip address you want to return, use awk '{print $2}'
Ex: >ip address | grep eth0 | grep inet | awk '{print $2}'

44. resolvectl status

Return information about the DNS server (including IP address)

Tip

cat /etc/resolv.conf Return information about the DNS server

45. ping

ping <name of the website/ipaddress>

Tip

Use ctrl+C to stop.

Note

To use only a specific number of response use ping -c <number> <name of the website/ipaddress>
To use only a specific size of packets use ping -s <number> <name of the website/ipaddress>

46. traceroute

traceroute <name of the website>To see the path through the internet to get to a website

47. netstat

To check what ports in use.

Tip

Modern version netstat -tulpn
Another command ss or ss -tulpn

48. iptables

sudo iptables -I INPUT -p tcp -, tcp --dport <port> -j ACCEPTTo allow a specific port through the firewall

Tip

Easy command sudo ufw allow <port>

Important

To execute above command below command might need to execute first
sudo ufw enable To check status use sudo ufw status

49. uname

uname -a To find information about the system.

Tip

Needs prettier version than above😀
Install neofetch sudo apt install neofetchf
Runneofetch

50. cal

A quick little calendar :)

51. free

To check how much memeory available in system and swap space.

52. df

To check how much space available (To be more specific use df -H)

53. ps

To list all processes

ps -aux More details

54. top

List processes running in real time

Tip

htop Much more prettier version of top.

55. kill

kill -KILL <pid> or kill -9 <pid> To kill the process with given id.

Tip

Use pkill -f <name of the process> In case the pid is not known.

56. systemctl

systemctl stop <service name> Stop a specific service.
systemctl start <service name> Start a specific service.
systemctl restart <service name> Restart a specific service

Tip

systemctl status <service name> To check the status
Use sudo if necessary when using systemctl command

57. history

Return a list of commands used.

58. reboot

sudo reboot To reboot the system

59. shutdown

sudo shutdown To shutdown the system after 1 minute
sudo shutdown -h now To shutdown the system now

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.