Page tree
Skip to end of metadata
Go to start of metadata

Navigating the Linux filesystem

  • List Directory Context- Will list all files and sub-directories from the Directory that you are currently in.

    ls
     
    [root@localhost agi-bin]# ls
    aastra-vm-greetings.php  ddns_client.php          parkfetch.agi
    aastra-vm.php            dialparties.agi          pbdirectory
    areminder                directory                phpagi-asmanager.php
    areminder-main.php       directory.agi            phpagi.php
    areminder-manager.php    directory.lib.php        queue_devstate.agi
    backuprecordings.php     enc                      sql.php
    broadcast_log.php        enumlookup.agi           trunk-alert.agi
    calllimit                fax.agi                  update_license.php
    calllimit.agi            fixlocalprefix           user_login_out.agi
    checksound.agi           license-1237432133.zl    vmnotify-audit.php
    class.phpmailer.php      list-item-remove.php     vmnotify-common.php
    class.pop3.php           LoadLicenseIfExists.php  vmnotify-main.php
    class.smtp.php           page.agi                 vmnotify-newvm.php
    [root@localhost agi-bin]# 
     
    # View all files including the owner and permissions use the -l flag
    [root@localhost agi-bin]# ls -l
    total 476
    -rwxrwxr-x 1 asterisk asterisk  3562 Aug  2 09:47 aastra-vm-greetings.php
    -rwxrwxr-x 1 asterisk asterisk  5995 Aug  2 09:47 aastra-vm.php
    drwxrwxr-- 3 asterisk asterisk  4096 Jan  4 16:34 areminder
    -rwxrwxr-- 1 asterisk asterisk   671 Jan 19 20:11 areminder-main.php
    -rwxrwxr-- 1 asterisk asterisk  1149 Jan 19 20:11 areminder-manager.php
    -rwxrwxr-- 1 asterisk asterisk   544 Jan 19 20:11 backuprecordings.php
    -rwxrwxr-- 1 asterisk asterisk  1246 Jan 19 20:11 broadcast_log.php
    drwxrwxr-- 2 asterisk asterisk  4096 Jan 18 15:35 calllimit
    -rwxrwxr-- 1 asterisk asterisk   248 Jan 19 20:11 calllimit.agi
    -rwxrwxr-- 1 asterisk asterisk  1872 Jan 19 20:11 checksound.agi
    -rwxrwxr-- 1 asterisk asterisk 74527 Jan 19 20:11 class.phpmailer.php
    -rwxrwxr-- 1 asterisk asterisk 10599 Jan 19 20:11 class.pop3.php
    -rwxrwxr-- 1 asterisk asterisk 25613 Jan 19 20:11 class.smtp.php
    -rwxrwxr-- 1 asterisk asterisk  1343 Jan 19 20:11 ddns_client.php
    -rwxrwxr-- 1 asterisk asterisk 32609 Jan 19 20:11 dialparties.agi
    -rwxrwxr-- 1 asterisk asterisk 13303 Jan 19 20:11 directory
    -rwxrwxr-- 1 asterisk asterisk  6750 Jan 19 20:11 directory.agi
    -rwxrwxr-- 1 asterisk asterisk 10452 Jan 19 20:11 directory.lib.php
    drwxrwxr-x 2 asterisk asterisk  4096 Jan 18 15:35 enc
    -rwxrwxr-- 1 asterisk asterisk  5683 Jan 19 20:11 enumlookup.agi
    -rwxrwxr-- 1 asterisk asterisk   248 Jan 19 20:11 fax.agi
    -rwxrwxr-- 1 asterisk asterisk  1613 Jan 19 20:11 fixlocalprefix
    -rwxrw-r-- 1 asterisk asterisk   712 Jan 18 15:27 license-1237432133.zl
    -rwxrwxr-- 1 asterisk asterisk  2003 Jan 19 20:11 list-item-remove.php
    -rwxrwxr-- 1 asterisk asterisk   953 Jan 19 20:11 LoadLicenseIfExists.php
    -rwxrwxr-- 1 asterisk asterisk  6459 Jan 19 20:11 page.agi
    -rwxrwxr-- 1 asterisk asterisk  2510 Jan 19 20:11 parkfetch.agi
    -rwxrwxr-- 1 asterisk asterisk 10262 Jan 19 20:11 pbdirectory
    -rwxrw-r-- 1 asterisk asterisk 31772 Jan  8 14:28 phpagi-asmanager.php
    -rwxrw-r-- 1 asterisk asterisk 65947 Jan  8 14:28 phpagi.php
    -rwxrwxr-- 1 asterisk asterisk  5913 Jan 19 20:11 queue_devstate.agi
    -rwxrwxr-- 1 asterisk asterisk 21211 Jan 19 20:11 sql.php
    -rwxrw-r-- 1 asterisk asterisk  1452 Jan 17 08:43 trunk-alert.agi
    -rwxrwxr-- 1 asterisk asterisk  1866 Jan 19 20:11 update_license.php
    -rwxrwxr-- 1 asterisk asterisk 20540 Jan 19 20:11 user_login_out.agi
    -rwxrwxr-- 1 asterisk asterisk   642 Jan 19 20:11 vmnotify-audit.php
    -rwxrwxr-- 1 asterisk asterisk   630 Jan 19 20:11 vmnotify-common.php
    -rwxrwxr-- 1 asterisk asterisk   647 Jan 19 20:11 vmnotify-main.php
    -rwxrwxr-- 1 asterisk asterisk   648 Jan 19 20:11 vmnotify-newvm.php
    [root@localhost agi-bin]#

     

     

     

  • Change Directory- Used to change the current directory you are in.

     

    cd
     
    # Change to the Directory where FreePBX Modules are located.
    cd /var/www/html/admin/modules/
     
    # Change back 1 directory.  Currently we are in /var/www/html/admin/modules/ and we want to go back 1 directory to /var/www/html/admin/
    cd ..
     
    # Change back 2 or more directories.  Currently we are in /var/www/html/admin/modules/ and we want to go back 2 directories to /var/www/html/
    cd ../..

     

     

  • Print Current Working Directory- Display what the directory path that you current are in.
pwd     
 
[root@localhost agi-bin]# pwd 
/var/lib/asterisk/agi-bin 
[root@localhost agi-bin]#

 

  • Copy a file- Copy a file from 1 location or directory to another location or directory 
cp   
 
# Below we will copy the fax.agi script to the /tmp/ directory 
[root@localhost agi-bin]# cp fax.agi /tmp/ 
[root@localhost agi-bin]#   
 
# Below we will use the copy command to make a new copy of fax.agi called fax.agi.old to keep a backup copy of the  
# script before we edit the file in the same directory that we are currently is which is the agi-bin directory 
[root@localhost agi-bin]# cp fax.agi fax.agi.old 
 
# To Copy a whole directory we need to pass the -r flag to tell it to recursively copy the directory.
# we will copy the whole modules directory to the tmp directory.  This will copy everything in modules dirctory
# and any dub directories within the modules directory.
[root@localhost agi-bin]# cp -rf /var/www/html/admin/modules/ /tmp/
 
# If we wanted to copy all files that ended in a .conf name from the /etc/asterisk/ directory to the
# current directory that we are in we could use the following command.
# The * is a wild character so *.conf means any file that has some characters and ends in .conf.
# The . at the end tells the copy command to copy the files into our current directory we are in.  You could easily
# replace the . with a directory path like /tmp/
[root@localhost tmp]# cp /etc/asterisk/*.conf .

 

  • Move a file- Move a file from 1 directory or location to another location.  You can also use the mv command to rename a file or directory 
mv     
 
 
# Below we will move the fax.agi script to the /tmp/ directory 
[root@localhost agi-bin]# mv fax.agi /tmp/ 
[root@localhost agi-bin]#   
 
# Below we will use the move command to rename fax.agi to fax.agi.save 
[root@localhost agi-bin]# mv fax.agi fax.agi.save 
[root@localhost agi-bin]#

 

 


  • No labels