• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

Roger Perkin

Learn Network Automation

  • Network Automation
    • Ansible
    • Python
    • Terraform
    • pyATS
    • Git
    • Postman
  • ISE
  • Cisco
    • SD WAN Training
    • Password Recovery
    • Software-Upgrade-Guides
    • BGP
    • Data Center
    • WIRELESS
  • Blog
    • CCIE Blog
  • COURSES
  • Menu Item

Linux Tips & Tricks for Beginners

In this post I will be listing all the Linux Tips & Tricks I come across in my journey to learn Linux.
This will be done on an Ubuntu 17.10 desktop installation, as I encounter each issue I will upload it here, mainly for my reference but also hopefully this can help someone else as well.

Delete non empty directory Linux

To delete a file in Linux you use the command rm <filename> linux will delete this file without question. To delete a a folder in Linux you use the command rmdir however you might get the following error. (Trying to delete a folder called test)

rm: cannot remove ‘test’: Is a directory

To remove a directory that contains other files or directories, use the following command.

rm -r test

In the example above, “test” is my folder I want to delete, you need to replace this with the name of the directory you want to delete. For example, if the directory was named “photos”, you would type rm -r photos at the prompt.

Executing the above command would delete all files and directories within the directory named in the command. However, it would also present a prompt for approval to delete each of the files. If you don’t want to receive a prompt for each file, use the following command instead.

rm -rf test

In the example above, the “test” directory, along with all files and directories within that directory, would be deleted with no prompt or message.

List contents of a folder with owner and permissions

If you want to see the contents of a folder you simply issue the command ls 

[email protected]:/etc/ansible$ ls 
ansible.cfg backup.yml hosts switch.yml templates vxlan_spine.ios

However if you want to see more details about each file, like it’s permissions and owner then you need to use ls -l 

[email protected]:/etc/ansible$ ls -l
total 40
-rw-r--r – 1 root root 18066 Jun 1 2017 ansible.cfg
-rw-r--r – 1 roger roger 704 Mar 27 13:17 backup.yml
-rw-r--r – 1 root root 126 Mar 24 09:04 hosts
-rw-r--r – 1 root root 120 Mar 24 09:08 switch.yml
drwxr-xr-x 3 root root 4096 Mar 26 00:51 templates
-rw-r--r – 1 roger roger 39 Mar 26 10:56 vxlan_spine.ios

For even more detail of the folder, showing all files use ll

[email protected]:/etc/ansible$ ll
total 60
drwxrwxrwx 4 root root 4096 Mar 27 13:17 ./
drwxr-xr-x 125 root root 12288 Mar 27 06:54 ../
-rw-r–r– 1 root root 18066 Jun 1 2017 ansible.cfg
-rw-r–r– 1 roger roger 704 Mar 27 13:17 backup.yml
drwxr-xr-x 8 roger roger 4096 Mar 27 13:19 .git/
-rw-r–r– 1 root root 126 Mar 24 09:04 hosts
-rw-r–r– 1 root root 120 Mar 24 09:08 switch.yml
drwxr-xr-x 3 root root 4096 Mar 26 00:51 templates/
-rw-r–r– 1 roger roger 39 Mar 26 10:56 vxlan_spine.ios

Here you can see a hidden folder .git which was not visible before

This command ll is sometimes (and it varies on which distro you are running) aliased to different commands

In my case running Ubuntu, ll is aliased to ls -alF 

To see this issue the following command

[email protected]:/etc/ansible$ type ll
ll is aliased to `ls -alF'

This is the actual command which is being run when you type ll 

Check out this post on how to run Linux on Windows 10

Windows Subsystem for Linux – Tutorial 

Previous Post: « vmwre esxi 6.5 login screen VMware Home Lab Server Tutorial using ESXi 6.5 Free
Next Post: Network Automation Tools List [Open Source] network automation tools featured »

Let’s get started

Take a look at my premium courses on Ansible, Nornir & Git or buy them all with the Network Automation Bundle!

Network Automation Courses

Social

Follow along on social media

Contact

Get in touch with me here

[email protected]

Navigation

Home

Blog

About

Contact

YouTube

Don’t forget to take a look at my YouTube Channel

youtube button

Copyright © 2021 · Roger Perkin · All Rights Reserved · Powered by Mai Theme