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

0
1
Loading...

In this a part of serial Linux Commands, we can be told the use of Linux Commands for File and Folder/ Directory Management. File and Folder control comprises those primary 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 identical, however now and again there are variations.

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

Serial Linux Commands:

Linux Commands for File and Folder/ Directory Management

1. View File and Folder main points

LINUX COMMAND PURPOSE / DESCRIPTION
  ls Display all information 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, comprises: dimension, ultimate up to date time…
  ls -a List the content material within the present folder, comprises hidden information
  pwd Provide the trail of running folder
  cd Change running folder (just like the command CD in MS-DOS)
  df Check disk house
  du Check Disk Usage: Sizes of folder bushes inclusive of all in their contents and the sizes of person information

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 tool (different tool, comparable to 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 tool
  mkdir MaOke 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 (no longer empty, use this command: rm -rf )
  mv Rename or Move dossier/folder
  rm Remove/Delete dossier(s)
  cp Copy dossier(s) to any 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
  to find Find dossier or content material in dossier, eg:
– to find  /and so forth  -name  inittab: Find all dossier within the folder /and so forth that its call incorporates 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

3. 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 via web page
  much less View dossier content material via line
  vi Open a dossier with VI editor
  tail  Reads the general few strains (10 via default). To show the general 100 line, use the command: tail 100 file-name
  head Reads the primary few strains (10 via 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)

4. Linux Command for Compression and Decompression

LINUX COMMAND PURPOSE / DESCRIPTION
  tar  -cvf Compress information/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 can attempt to edit dossier PHP.INI the use of VI editor. Firstly, kind this command:

vi /and so forth/php.ini

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

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

– Finally, save the dossier with under command:

:wq

And listed here are different instructions for VI editor:

:w -Save the dossier however does no longer 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’s no exchange
: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 under command:

mkdir /mnt/New-Partition

– Then, use MOUNT command:

mount /dev/supply /mnt/New-Partition

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

Find/ Search for dossier/ dossier content material in Linux

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

grep < keyword/ condition>

– With a protracted content material, we will use the command MORE to show textual content via 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 wish to have to any extent further assist, be happy to touch us via leaving a touch upon every article.
Don’t fail to remember to apply us on social channels to get newest pointers.