Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Command: Difference between revisions

From atl.wiki
m (Chore: Update categories)
m (Fix spelling of link)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
When using [[Linux]], sooner or later, there's a good chance you'll end finding yourself in front of a [[Terminal]] and having to paste in or type in things that recommended to you by people on the internet. What you are doing when this happens is running a 'Command'. This is telling a program or utility to behave in a certain way or to perform some sort of action. Some common commands include "[[fastfetch]]", "[[nano]]", "[[cat]]", etc.
When using [[Linux]], sooner or later, there's a good chance you'll end finding yourself in front of a [[Terminal Emulator|Terminal]] and having to paste in or type in things that recommended to you by people on the internet. What you are doing when this happens is running a 'Command'. This is telling a program or utility to behave in a certain way or to perform some sort of action. Some common commands include "echo", "mv", "[[cat]]", etc.


When running commands, You may have to rely on functions reserved to privileged users. When this happens you will likely start your command with "sudo" followed with your original command. [[sudo]] Tells your computer to 'do' something as a 'super user' which will allow you to bypass restrictions.
When running commands, You may have to rely on functions reserved to privileged users. When this happens you will likely start your command with "sudo" followed with your original command. [[sudo]] Tells your computer to 'do' something as a 'super user' which will allow you to bypass restrictions. It should be important to note that '''sudo is a seperate package''' and won't come pre-installed with certain [[Linux Distributions|distributions]]. If this is the case, you need to use something like "su" to log in as root and then run your command as root or install sudo as root.


Furthermore, with commands you will likely need to include "options" that specify to the program how you want it to behave. One of the most common options is "--help", which will usually tell program to list all of its options. An example would be as follows
Furthermore, with commands you will likely need to include "options" that specify to the program how you want it to behave. One of the most common options is "--help", which will usually tell program to list all of its options. An example would be as follows
Line 27: Line 27:
When providing files you can either choose to provide one from the [[Working Directory]] (Like shown) or you can provide a file from anywhere in the [[Filesystem]] that your user has access to. Here is an example of a command on a file that you want to edit in your documents folder.
When providing files you can either choose to provide one from the [[Working Directory]] (Like shown) or you can provide a file from anywhere in the [[Filesystem]] that your user has access to. Here is an example of a command on a file that you want to edit in your documents folder.
  nano ~/Documents/example.txt
  nano ~/Documents/example.txt
You will notice that I started describing the file location, I used the tilda sign "~". In linux and some other OS, The Tilda is a faster way to describe the users home folder. It is effectively the same thing as typing the full [[directory path]] except that it is much faster. Here is what it would look like to type the whole directory path
You will notice that I started describing the file location, I used the tilda sign "~". In linux and some other OS, The Tilda is a faster way to describe the users home folder. It is effectively the same thing as typing the full [[Directory Path|directory path]] except that it is much faster. Here is what it would look like to type the whole directory path
  nano /home/user/Documents/example.txt
  nano /home/user/Documents/example.txt
These two locations are the exact same except one of them is much simpler to type, otherwise they are the same.
These two locations are the exact same except one of them is much simpler to type, otherwise they are the same.

Latest revision as of 10:27, 30 October 2024

When using Linux, sooner or later, there's a good chance you'll end finding yourself in front of a Terminal and having to paste in or type in things that recommended to you by people on the internet. What you are doing when this happens is running a 'Command'. This is telling a program or utility to behave in a certain way or to perform some sort of action. Some common commands include "echo", "mv", "cat", etc.

When running commands, You may have to rely on functions reserved to privileged users. When this happens you will likely start your command with "sudo" followed with your original command. sudo Tells your computer to 'do' something as a 'super user' which will allow you to bypass restrictions. It should be important to note that sudo is a seperate package and won't come pre-installed with certain distributions. If this is the case, you need to use something like "su" to log in as root and then run your command as root or install sudo as root.

Furthermore, with commands you will likely need to include "options" that specify to the program how you want it to behave. One of the most common options is "--help", which will usually tell program to list all of its options. An example would be as follows

cat --help

In this case, the 'cat' utility would respond to this command with the following:

Usage: cat [OPTION]... [FILE]...

Concatenate FILE(s) to standard output.

With no FILE, or when FILE is -, read standard input.

  -A, --show-all           equivalent to -vET

  -b, --number-nonblank    number nonempty output lines, overrides -n

  -e                       equivalent to -vE

  -E, --show-ends          display $ at end of each line

  -n, --number             number all output lines............

(Shortened to maintain focus on topic)

These options can either mildly or even wildly change the behavior of programs. Unfortunately, options are specific to each program and the options for one program will behave totally different between different programs. Thankfully, "--help" is always there and ready. If --help isnt enough, you can always run "man" before a program similarly to how you would run "sudo", and it will tell you how these programs behave, usually in a slightly different way.

Very often, Commands will also request a File to run its commands on. For example, nano requires you to choose a file for it to create or edit, and you would provide it in the same line that you run nano on like the following;

nano example.txt

When providing files you can either choose to provide one from the Working Directory (Like shown) or you can provide a file from anywhere in the Filesystem that your user has access to. Here is an example of a command on a file that you want to edit in your documents folder.

nano ~/Documents/example.txt

You will notice that I started describing the file location, I used the tilda sign "~". In linux and some other OS, The Tilda is a faster way to describe the users home folder. It is effectively the same thing as typing the full directory path except that it is much faster. Here is what it would look like to type the whole directory path

nano /home/user/Documents/example.txt

These two locations are the exact same except one of them is much simpler to type, otherwise they are the same.