Hardware

Best commands for linux: basic, administration, permissions ...

Table of contents:

Anonim

It is always good to have a little help when we are learning something new. With this in mind, at Professional Review we have prepared a reference guide with the basic and most used commands to help those who are now discovering the penguin universe. Although the system has evolved a lot over the years and has become extremely simple and user-friendly for the novice, the Linux command terminal is an intrinsic part of the operating system; and it is a powerful tool.

Thus, it is good to know it in case you need to use it one day. Also, this guide is intended to disprove the idea that commands are for experts only. Here you can discover how easy they are to use.

We recommend reading:

  • Quick guide to basic commands for Ubuntu and linux. Help commands in the Linux terminal.

Basic Linux Commands

We organize the main commands into categories, both to facilitate memorization and to facilitate consultation. Now you just have to open the terminal and get down to work to enjoy the power of the Linux terminal. We start with the main file commands:

  • ls: list the directoriesls -al: list the directories also showing the hidden files cd dir: change the current directory to the one specified (replace the dir variable with the folder name) cd: send to the / home directory (personal files) pwd: show current directory pathmkdir dir *: create a specified directory (replace dir variable with folder name) rm file: delete specified file (replace file variable with name of file to be removed) rm -r dir: delete the specified directory (replace the dir variable with the folder name) rm -f file: forcibly delete the specified file (-f de force) (replace the file variable with the name of the file you want to delete) rm -rf dir: forcibly deletes the specified directory (replace the dir variable with the folder name).cp -r file1 file2: copy “file1” to “file2” (replace the file * variable with the name re of the file) cp -r dir1 dir2: copy directory1 to directory2; create directory2 in case it does not exist (substitute dir for directory name) mv file1 file2: can be used to rename or move file1 to file2. If file2 is an existing directory, move file1 into the "file2" directory (replace the file variable with the file name) ln -s file link: create a symbolic link (shortcut) for a file (replace the file variable with name of the file and the link with the name that the shortcut will have) touch file: create or update the file (replace the file variable with the name of the file) cat> file: redirect the standard input to a file (replace the file variable by file name) more file: shows the content of a filehead file: shows the first 10 lines of a file archive file: shows the last 10 lines of a file archive -f file: shows the content of a file while updating (increases size), from the last 10 lines

Process management

  • ps: shows active user processes in real-timetop: shows all processes running in real-timekill pid: kills a specific process with the ID number (replace pid with the process number) killall proc: kills all processes with the specified name (replace proc with the process name) bg: list of stopped or second job plansofg: brings the most recent job to the first planofg job: brings the job "job" to the foreground (replace job with the process name)

File permission management

chmod octal file: change the permissions of the file "file" to octal, which can be specified separately for "user", "group" and "others". The octal values ​​are represented below:

  • 4 - read (r from read) 2 - write (w, from write) 1 - execute (x, execute)

Explanation: To set permissions, the values ​​above are added together. For example, to assign the owner of the file (user) full access to read (r), write (w) and execute (x), simply add the octal value 4 + 2 + 1 = 7. Assuming you want to limit the access for members of the "group", allowing only reading and writing, just add 4 + 2 = 6. Gathering the two examples cited, it would remain: chmod 760 (r for the user, w for the group and 0 for others or "Rw-")

Other examples:

  • chmod 777: read (r), write (w) and execute (x) for all ("user", "group" and "others") chmod 755: "rwx" for the "owner" (user), "rw" for the "group" and "others"

For more information, type in the terminal: man chmod

SSH: remote connection

ssh user @ host: connect to the host as a user (example: ssh andres @ myserver)

ssh -p port user @ host: connects to the host on the specified port (replace "port" with the configured port number)

ssh-copy-id user @ host: add the password for the host and user of that host; it is used to activate the login without password with the use of keys

Commands for searches

grep sequence files: search for the sequence of the files (replace the sequence and files with the values ​​corresponding to the investigation)

grep-r dir sequence: search recursively by sequence in dir directory

command | grep sequence: search for the sequence in the command output (substitute command and sequence according to the values ​​to be searched)

locate file: find all instances of a file (replace the file variable with the file name)

System information

  • date: shows the current date and timecal: shows a calendar for the current monthuptime: shows the system uptimew: shows who is onlinewhoami: shows who is onlinefinger user: shows the user informationuname -a: shows the information of corescat / porc / cpuinfo: show the information of the CPUcat / proc / meminfo: show the information of the memoryman command: open the manual of the specified command (replace the command variable with the name of the command you want to know) df: show the use from diskdu: shows the use of space in a directory free: shows the use of memory and swapwhereis application: shows the possible locations of the application (replace application with the name of the program) which application: shows which application will run by default (replace application by program name)
WE RECOMMEND YOU Managing file and folder permissions in Linux

File compression

  • tar cf package.tar files: create a TAR package (named package.tar) with the specified files (replace the files variable with the file name) tar xf package.tar: extract the files from package.tar (replace the package variable.tar by file name) tar czf pacote.tar.gz files: create a TAR package (named pacote.tar.gz) with GZiptar compression xzf pacote.tar.gz: extract a TAR package (named pacote.tar. gz) with GZiptar compression cjf package.tar.bz2: create a TAR package (named package.tar.bz2) with BZip2tar compression xjf package.tar.bz2: extract a TAR package with BZip2gzip compression file: compress a file and name file.gz (replace file variable with file name) gzip -d file.gz: unzip file.gz to file (replace file.gz variable with file name)

Commands for network connection

ping host - Sends an ICMP (ping) packet to the host and displays the result (replace the host variable with a website's domain or IP number)

domain whois: returns information about the domain (substitute the domain variable for a website address or IP number)

dig domain: returns the DNS information for the domain (replace the host variable with a website's domain or IP number)

dig -x host: show the inverse return for a host

wget file: download file (file) (replace the file variable with the file's online address)

wget -c file: continues interrupted download of a file (replace the file variable with the file's online address)

Package installation

Installation from source code; the commands must be entered in the sequence in a terminal, one at a time:

  • ./configuremakemake install

Installer Commands

dpkg -i package.deb: install a DEB package (Debian distros) (replace the variable package.deb with the name of the program package)

rpm -Uvh package.rpm: installs an RPM package (Distros that use RPM) (replace the variable package.rpm with the name of the program package)

Global shortcuts

  • Ctrl + C: Cancel current command running Ctrl + Z: For current system, return with fg in the foreground or bg in the background Ctrl + D: Exit the current session; similar to the command exitCtrl + W: delete a word on the current line Ctrl + U: delete the entire line Ctrl + R: press the key to display a command today !!: repeat the last command exit: close the session of the current session

It is good to know and know some of the basic commands in the terminal, this in addition to increasing your degree of knowledge about the operating system, helps a lot saving you hours of research.

Finally, we leave you a table with the main commands exposed in this article, it will surely serve to give you a quick look.

What did you think of our article on the basic commands for the linux terminal ? Did you find it interesting? Are you interested in uploading a particular article on the web?

Hardware

Editor's choice

Back to top button