Linux Basics/Basic commands
Root vs user permission
edit[root@ubuntu ~]#
- root permission[user@ubuntu ~]$
- user permission
User can execute things with root permission that the user wouldn't do with base permission likeapt install
, but using sudo does the same job as if you were in root. Linux Basics/User management (System administrator) chapter dives deeply into this topic.
Commands
edit<command> --help
: it will display all the switches for the commandcd
: change directory (→ cd .. = it will go back by one folder/directory)pwd
: print working directory – it'll display which folder you're in right noww
: it shows who are logged in and what they are doing (w <username> displays the particular user's activity)who
: it displays only the tty interface, the date and ip address with the usernamels
: listing files in a directoryls -a
: it lists all the hidden files aside the non-hidden onesls -A
: same as previous, but it lacks . and .. (. means the current folder, .. means previous folder)ls -l
: detailed directory listls -al
: based on the commands above: detailed directory list + hidden files with . and ..
exit
: it'll quit the user from the shell and close the shellsudo <command>
: you can do commands as superusermv
: move, moving from A to B: syntax: mv <source> <destination>. It can be used for renaming too.mc
: midnight commander's command (you have to install it, because most distros don't contain mc by default)touch file
: creating "file" named fileecho something
: "something" will be directed to the echo's standard output.nano file
: editing "file" named file with nano (by default on some distros it's not installed, so you have to install it)less file
: outputting "file" named file to the terminal, but you can move in the word viewer, and you can quit from it by pressing qrm
: remove, deleterm -r
: recursive, so the rm command will delete everything that is givenrm -f
: force, so without any arguments the folder will be deletedrmdir
: folder deletion, but rm -rf is simpler to delete a folder with files.
mount
: connecting devicesumount
: disconnecting devicesln
: creating link (hard-link)ln -s
: creating soft-link/symlink the differences between and softlink is written in Linux Basics/The structure of Linux chapter)
df
= disk free = it says how many free spaces are on each partitiondu
= disk usage; you have to give parameters, else it's gonna list all the directoriesdu /home
: it's gonna list the content of /home and the usage of the foldersdu -h
it says which folder and file how many kB, MB, GB does it take, if we won't put this, it's gonna list everything in bytesdu -s
summarizes (it takes every folder as one, and it'll write the sum of their size)
free
= free memory and swap spacetop
(black and white) /htop
(color) = it displays the currently running apps (like Task Manager in Windows)uname
= displays info about the system, -a switch tells everything about the kernel
Output in Manjaro:Linux manjaro 5.6.11-1-MANJARO #1 SMP PREEMPT Wed May 6 10:20:32 UTC 2020 x86_64 GNU/Linux
ntpdate <server>
= it's gonna update your system's time based on the time server address you gave (like time.nist.gov => ntpdate time.nist.gov)uptime
= how long have your system been running, and how much it's loadednetstat
= network statisticsman
= It opens the manual pages of the command, short and straightforward descriptioninfo
= same as man, just it's more common in Red Hat systems
Network managemenent
editifconfig
= ip address, network settings, amount of sent and received packagesiwconfig
= same as ifconfig, just this is for wireless settingsping
(pinging an IP address) : ping www.google.com ; ping -c 3 www.google.com (we can give after the -c switch how much packets do we want to send to a page)ifup
= interface up – it runs a script when it's enabled (e.g. ifup eth0 -> it enables eth0 interface)ifdown
= interface down – same as ifup, just here we disable the interface e.g. ifdown eth0ifstatus
- interface statusifstat
– it monitors the upload/download speed of the interfaces
User management
editadduser
/useradd
– user creationuserdel
– user deletionchmod
- change mode - we can set the permissions for the files and directories(Linux Basics/Filesystem, permissions has more information on this)chown
– change ownerusermod
– modifying user
package management commands: dpkg, rpm, apt, yum, dnf, pacman, zypper stb.
Other commands
editclear
– clears terminalchroot
– changing root folderkill
– killing/terminating process based on PID (ps -A displays that)kill -9
– kills every subthreadkillall
- kills the list's all elements but kill -9 @(...) is easier
halt
- computer shuts down, but its PSU still goes(in case of ATX v2 PSUs)shutdown
/sudo init 0
– computer shuts down completelyreboot
– computer reboots –sudo init 6
/bin/bash
– bash command promptservice
– we can start/restart services running on the computersystemctl
– same as servicecron
: computer does things without your input (in intervals, startups, shutdowns), cron daemon runs these (hourly, daily, weekly..)crontab
: user's own cron settingcrontab -e
: editing crontab
/etc/skel folder: the content of this folder goes to the new user's home folder (skel = skeleton)
/etc/sudoers file: those users who can use sudo. (Linux Basics/Filesystem, permissions explains it in depth)