5 - Object management in Linux

File creation in Linux How do we create a file or a dir in Linux? There are several different commands that can be used to open, create, edit, or view a file in Linux. Create a new file VI command: -as default on most of the Linux OS we will have the "vi" command. "VI" command can be also used to edit already created files. How do we use the "vi" command to create a new file : Syntax: -to create or edit a file:

    vi "file name"."file extension" + ENTER
This is how a empty file looks like, you can edit this file by pressing the "i" key(insert). To save and exit the file : Syntax:
    ESC + :wq + ENTER
To exit the file without saving the the altered data : Syntax:
    ESC + :q! + ENTER
  
General Syntax used with "VI":
    vi [ -| -s ] [-l] [-L] [-R] [ -r [ filename ] ] [-S] [-t tag] [-v] [-V] [-x] [-w] [-n ] [-C] [+command | -c command ] filename
 
How to remove a file in Linux: Command : rm [option] "file name" Option [-f] -Forcefully remove file. Other Linux editos that can be used: cat -Allows you to look, modify or combine a file. Sintax:
  cat "filename" [-n] [-b] [-u] [-s]
[-n] -Precede each line output with its line number. [-b] -Number the lines, as -n, but omit the line numbers from blank lines. [-u] -The output is not buffered. (The default is buffered output.) [-s] -cat is silent about non-existent files. Examples
  cat file1.txt file2.txt >
  file3.txt
-Reads file1.txt and file2.txt and combines those files to make file3.txt. tail -Will show the last part of the file. Syntax
  tail [+ number] [-l] [-b] [-c] [-r] [-f] [-c number | -n number] [file]
To get more info about this command you can just open a bash and type :
  man tail
- this will pull out the manual for this command. There are many Linux editors that are in use but we will only use the ones above. Now that we have learned how to create files let's see how to create directory or folder. The command used for creating directory or folders is :
  mkdir
-make directory. The general syntax is
  mkdir [option] directory
Options:
  • [-m mode] Set permission mode (as in chmod), not rwxrwxrwx - umask.
  • [-v] Print a message for each created directory.
  • [-Z] (SELinux) set security context to CONTEXT.
  • [directory] The name of the directory that you wish to create.
  • To remove a dir just use the "rmdir" remove directory Command : Sintax:
      rm[option]"dir name";
    Options:
  • [-r], [-R] --recursive (remove directories and their contents recursively);
  • Note - if you try to delete the directory using rmdir command and you have some others files or other directorys you will get and error message. So in order for us to delete the dir and also what is inside of it we will use the "rmdir" option command "-r": Syntax
      rmdir -r "dir name"
    Example: Very important : Never run (rm -rf / or rm -rf *)as an administrator or normal Linux user.this command will erase everything you have on your computer, and believe me Linux commands from the bash line are pretty quick, there is no way back from this(only a backup restore will save you). I will not demonstrate this command asi do not want my file system to go empty.