(Linux Command Line) Part 2 – Linux Commands for File and Folder/ Directory Management

0
54

In this a part of serial Linux Commands, we will be able to be informed the use of Linux Commands for File and Folder/ Directory Management. File and Folder control contains those major duties: disk and partition control, create dossier/ folder, edit dossier content material, rename dossier/ folder, set permission for consumer(s), transfer dossier/ folder.

Remember that Commands in CentOS and Ubuntu are very equivalent, however on occasion there are variations.

Linux Commands for File and Folder/ Directory Management

Serial Linux Commands:

  >> Part 1 – Linux Commands for Server Management and Monitoring
  >> Part 2 – Linux Commands for File and Folder/ Directory Management
  >> Part three – Linux Commands for File Editor in Linux (CentOS, Ubuntu)
  >> Part four – Linux Commands for Network Configuration in Linux (CentOS, Ubuntu)
  >> Part five – Other Useful Linux Commands (CentOS, Ubuntu) you want to grasp

Linux Commands for File and Folder/ Directory Management

1. View File and Folder main points

LINUX COMMAND PURPOSE / DESCRIPTION
  ls Display all recordsdata and folders within the present folder
  ls foldername List the content material within the foldername
  ls -l List the content material within the present folder, contains: measurement, final up to date time…
  ls -a List the content material within the present folder, contains hidden recordsdata
  pwd Provide the trail of operating folder
  cd Change operating folder (just like the command CD in MS-DOS)
  df Check disk area
  du Check Disk Usage: Sizes of folder timber inclusive of all in their contents and the sizes of particular person recordsdata

2. Linux Commands for File and Folder actions (create, delete/ take away, seek…)

LINUX COMMAND PURPOSE / DESCRIPTION
  mount Mount/ Attach dossier machine from a garage software (different software, reminiscent of a CDROM, DVD, floppy disk or USB key power)
mount /mnt/floppy: Attach a floppy disk
umount /mnt/floppy: Detach a floppy disk
mount /mnt/cdrom: Attach a CD-ROM.
  umount Unmount dossier machine from a garage software
  mkdir MaOkaye DIRectory: Create a brand new folder, eg: mkdir Folder-Name
  contact Create a brand new and empty dossier.
  rmdir Remove/ Delete an empty folder(s) (to delete a folder with content material (now not empty, use this command: rm -rf )
  mv Rename or Move dossier/folder
  rm Remove/Delete dossier(s)
  cp Copy dossier(s) to every other location eg: cp source-file.txt des-file.txt
  chmod Set dossier/ folder permission. Format: chmod right-code dossier/folder-name
  wget Download a dossier from a URL
  in finding Find dossier or content material in dossier, eg:
– in finding  /and so on  -name  inittab: Find all dossier within the folder /and so on that its call comprises inittab
– grep textual content filename: Search for string textual content in filename
  lpr Print a dossier
  lprm Cancel printing queues
  lpq Display the listing of printer queues
  echo str Copy str to the command window

three. Linux Commands for File Editor

LINUX COMMAND PURPOSE / DESCRIPTION
  wc Count the selection of strains, phrases and characters within the textual content
  cat Display dossier content material
  extra View dossier content material by way of web page
  much less View dossier content material by way of line
  vi Open a dossier with VI editor
  tail  Reads the general few strains (10 by way of default). To show the general 100 line, use the command: tail 100 file-name
  head Reads the primary few strains (10 by way of default). To show the primary 100 line, use the command: head 100 file-name
  ln existingfile new-link Create a trail to a dossier (arduous hyperlinks)

four. Linux Command for Compression and Decompression

LINUX COMMAND PURPOSE / DESCRIPTION
  tar  -cvf Compress recordsdata/folders with.TAR layout
  tar  -xvf Decompress a .TAR dossier
  gzip Convert .TAR dossier to .TAR.GZ dossier
  gunzip Convert .TAR.GZ dossier to .TAR dossier
  tar -xzf Decompress a .TAR.GZ dossier, eg: tar -xvf archive.tar
  tar -zxvf Decompress a .tar.bz2 dossier
  tar -jxvf Decompress a .tar.gz2 dossier
  tar -cvzpf Compress a folder, eg: tar -cvzpf archive.tgz /house/instance/public_html/folder
  unzip Decompress a .zip dossier

How to make use of Linux Commands for File and Folder Managment

Edit dossier with VI textual content Editor

For instance, we will be able to attempt to edit dossier PHP.INI the use of VI editor. Firstly, sort this command:

vi /and so on/php.ini

– Press key Insert to go into “Editing mode” then edit the dossier content material.

– When you’re completed, press Insert key yet again time to go out Editing mode.

– Finally, save the dossier with beneath command:

:wq

And listed below are different instructions for VI editor:

:w -Save the dossier however does now not go out VI editor
: x – Save the dossier and go out VI editor
:wq – Save the dossier and go out VI editor
:w – Save the content material into a brand new dossier
:q – Exit VI editor if there is not any trade
:q! – Exit VI editor
:r – Read a dossier

Create a brand new Partition in Linux

– Firstly, create a brand new folder in /mnt with the beneath command:

mkdir /mnt/New-Partition

– Then, use MOUNT command:

mount /dev/supply /mnt/New-Partition

(/dev/supply is the garage software (partition) we need to connect to the dossier machine)

Find/ Search for dossier/ dossier content material in Linux

– To seek for dossier by way of filename, use the command: FIND

– To seek for a string (textual content) in dossier content material, use the command GREP:

grep < keyword/ condition>

– With an extended content material, we will be able to use the command MORE to show textual content by way of web page

– To get all dossier content material, use the command: CAT

cat < file name>

– To View just a few content material within the most sensible or backside of a dossier, use the command HEAD or TAIL.

Cheers!

If you want any longer lend a hand, be happy to touch us by way of leaving a touch upon every article.

Don’t fail to remember to practice us on social channels to get newest pointers.