announcement

Share the latest technology trends or photos of gadgets you love.

Linux Commands for Beginners

Linux Commands for Beginners

To learn using open source operating systems, it is very necessary to know at least the basic Linux commands. Here's all that you need to know.
Yash Gode
Last Updated: Apr 9, 2018
With Linux based operating systems like Fedora and Ubuntu gaining ground, many firms in the Information Technology (IT) industry are opting to shift to these, instead of purchasing licensed ones. The most important part in learning Linux is to get used to working with commands. Linux hosts a huge collection of commands to be executed. The difficulty in learning Linux commands, scares off beginners off this secure platform. A composite collection of Linux commands for beginners can prove helpful. Here we will check some important and most widely used commands in Linux and what they do, with an example.
Directory Function
  • ls: Will display the names of all files and sub-directories in the current or the working directory. There are various add-ons, which when post-fixed to the ls command, have different actions.
    -a lists the hidden files.
    -d shows the name of the current directory.
    -F shows directories with a trailing '/' in name.
    -g shows group ownership of file in the form of a long list.
    -i prints the node number of each file.
    -l gives a long list giving details about files and directories.
    -R lists all sub-directories encountered.
    -t sorts by modified time instead of name.
  • cd: This command is used to change directories. If we use cd.. we move to the parent directory. The absolute path appears if cd /home is entered. The system is returned to the user's home directory when only cd is used.
  • mkdir: Makes new directory of the name specified after the command. The path given should be relative i.e. as a sub-directory to the current directory. Example: mkdir my_dir will make a new directory with name 'my_dir'.
  • rmdir: Removes the directory stated after the command. The deletion occurs only if the directory is empty. If it is not empty you need to use rm -r command followed by the directory name. Example: rmdir my_dir deletes the empty my_dir directory. While rm -r my_dir will delete a directory even if it has some content.
File Functions
  • more: This command will run or display the file specified by the filename.
  • cp : Copies file1 to file2, keeping the original file1 as it is. For this, both the files must be in the same working directory. In case there's change in directory, the path of the other directory must be specified.
  • mv : Moves file1 to file2 and removes file1 from its original location.
  • rm: This command will remove the given file from the system. There are various wildcards available, which, if we use, can give us selective removal options. Example: rm file removes the file with name 'file'. rm h*c will remove the files beginning with 'h' and ending with 'c'. rm* deletes all files from the current directory. rm -i* deletes all files by confirming before deleting every file.
  • rm -r/: This horrifying command will delete all the directories in your system if you're an admin user and then you should be sent to a madhouse for such an act.
  • find /user -: Searches and finds file named 'flnm' in the sub-directories of the directory named 'user'.
Access Permission
chmod - change file access permissions.

Usage: chmod - <filename/directory>
The value of decides the access rights on the file which should be in the current directory.
specifies the kind of rights being granted.
specifies file or directory that is asking permissions for rights. In case of a directory, you must post-fix '-R' to chmod.
Here's a list of various rights in an alphanumeric format that can be granted.
u - User who owns the file
g - Group that owns the file
o - Other
a - All
r - Read the file
w - Write or edit the file
x - Execute or run file as a program
Numerical Permissions:
CHMOD can also be attributed by using numeric permissions:

400 - Read by owner
040 - Read by group
004 - Read by anybody
200 - Write by owner
020 - Write by group
002 - R/W by anybody
100 - execute by owner
010 - execute by group
001 - execute by anybody

These are the basic and essential Linux commands that beginners can put to use. There are tons of other commands, but it is always advisable to first get a hang of these basic ones, because without mastering these, a beginner cannot progress to the higher level in learning Linux.