Basic Linux Commands

Basic Linux Commands

When We talk about Linux commands, what we are really talking about is the Linux system itself. These small number of Basic Linux commands will not make you a genius or a Linux expert instead, it’ll help you get started with Linux.
  1. Sudo
  2. Every single command that needs root’s permission needs this sudo command. You can use sudo before each command that requires root permissions –
    $ sudo su
  3. ls (list)
  4. list command terminal will show you all the files and folders of the directory that you’re working in. Let’s say I’m in the /home folder and I want to see the directories & files in /home.
    /home$ ls
  5. cd
  6. Changing directory (cd) is the main command that always be in use in the terminal. Just type the name of the folder you want to go in from your current directory.
    Let’s say I’m in /home directory and I want to move in usr directory which is always in the /home. Here is how I can use cd commands –
    /home $ cd usr/home/usr $
    If you want to go up just do it by giving double dots (..) as the parameter.
  7. mkdir
  8. create a new folder or sub folder. You can use mkdir command to do that. Just give your folder name after mkdir command in your terminal.
    ~$ mkdir folderName
  9. cp
  10. Using cp will help you to copy-and-paste the file from the terminal. First, you determine the file you want to copy and type the destination location to paste the file.
    $ cp src des
    Note: If you’re copying files into the directory that requires root permission for any new file, then you’ll need to use sudo command.
  11. rm
  12. rm is a command to remove your file or even your directory.
    $ rm myfile.txt
    You can use -f if the file need root permission to be removed.
    $ rm myfile.txt
    you can use -r to do recursive removal to remove your folder.
    $ rm myfile.txt
  13. apt-get
  14. to install, remove and upgrade any package we’ve Advanced Packaging Tool (APT) package manager. The apt-get command will help you install the software you need to run in your Linux. It’s perform installation, upgrade, and even removing your software.​In other distributions, such as Fedora, Centos there are different package managers. Fedora used to have yum but now it has dnf.
    $ sudo apt-get update
    $ sudo dnf update
  15. grep
  16. You need to find a file but you don’t remember its exact location or the path. grep will help you to solve this problem. You can use the grep command to help finding the file based on given keywords.
    $ grep user /etc/passwd
  17. cat
  18. As a user, you often need to view some of text or code from your script. Again, one of the Linux basic commands is cat command. It will show you the text inside your file.
    $ cat CMakeLists.txt
  19. poweroff
  20. And the last one is poweroff. Sometimes you need to poweroff directly from your terminal. This command will do the task. Don’t forget to add sudo at the beginning of the command since it needs root permission to execute poweroff.
    $ sudo poweroff
  21. unzip
  22. If the unzip command isn't already installed on your system, then run:
    sudo apt-get install unzip
    After installing the unzip utility, if you want to extract to a particular destination folder, you can use:
    unzip file.zip -d destination_folder
  23. Zip
  24. zip -r archive.zip dir1 -x dir1/ignoreDir1/**\* dir1/ignoreDir2/**\*
  25. Folder Permission
  26. chmod -R 777 /www/html/test. The -R (or --recursive) options make it recursive.
    chmod g+rx,o+x /www/html/test.
    chmod a-w file (removes all writing permissions)
    chmod o+x file (sets execute permissions for other (public permissions))
    chmod u=rx file (Give the owner rx permissions, not w)
    chmod go-rwx file (Deny rwx permission for group, others)
    chmod g+w file (Give write permission to the group)
    chmod a+x file1 file2 (Give execute permission to everybody)
    chmod g+rx,o+x file (OK to combine like this with a comma)

    u = user that owns the file
    g = group that owns the file
    o = other (everyone else)
    a = all (everybody)

    r = read aces to the file
    w = write access
    x = execute (run) access

Tags

We are Recommending you:

Leave a comment

Comments