What is a command?

Basic description of command structures

What is a command?

A command is tool in the terminal that typically accepts options and arguments. The syntax is generally command [options] (arguments) many commands can be run with or without arguments and most can be run without options in this instance we'll utilize ls as our example.

ls 
# without any arguments this list all files in the current directory
# output will look like the following: 
directory1 directory2 file1 file2 

# ls can be run with options one example is the all option
# all can be run as such 

`ls --all` OR `ls -a`
# Options typically have long and short forms. The short form is called 
# with a single `-` while the long form is called with a double `--`
# without an argument this will still list items in the current directory
# however this option will also show hidden files
# the ouput will be similar to the following: 
.bashrc .hiddendirectory .hiddenfile .ssh directory1 directory2 file1 file2

# you can also call ls with both options and an argument let's look into 
# our directory1 directory 

ls -a directory1
# this is an empty directory so the only results will be the directory
# itself `.` and the reference to the directory before it `..`
./ ../ 

ls lists files and directories within the current directory it has many options and is a good practice command as it won't break anything. If you want to list the contents of a directory that you are not it use an argument that refers to the desired directory for example from the /home/theo directory I can list the contents of Desktop by running ls Desktop/

To find out more about this command or any other utiliize man. From your terminal run man ls

Last updated