Click here for "Safe Air Conditioner Repair and Proper Freon Recovery".

Directory and file operations

Directory and file operations

Show all files in a directory

To view the files in a directory, use the "ls" command. However, files beginning with a ". (dot) is a hidden file and cannot be displayed by the "ls" command. ." (dot), you can use the "ls" command with the option "-a".
Directory and file operations

Checking symbolic links

A symbolic link looks like a normal file, but the actual file is in a different directory. To check whether a file is a symbolic link or not, run the ls command with the "-l" option.
Directory and file operations

Change the default permissions for files and directories

When you create a new file or directory, it will have default permissions. To change the default permissions, use the umask command. Permissions in octal notation flag notation     rwx corresponding octal number      421
Directory and file operations

Changing the ownership of files and directories

To change the ownership of a file or directory, use the chown command. If you want to change the ownership of all files in a directory, run it with the -R option.
Directory and file operations

Create a multi-level directory in one go

To create a directory, specify the directory name as the argument of the "mkdir" command and execute it, but if you specify a directory that does not exist when specifying a directory over a multi-level hierarchy, an error will occur. In such a case, you can force a non-existent directory to be created and create a multi-level directory at once by executing with the option "-p".
Directory and file operations

Delete the directory (and everything in it)

Delete the directory (and everything in it) To remove a dire...
Directory and file operations

Check the number of characters and lines in a file

The wc command is used to check the number of characters and lines in a file. To check the number of characters, use "-c" as an option, and to check the number of lines, use "-l". To execute the wc command, specify the name of the file you want to investigate as an argument.
Directory and file operations

Display the contents of a file with line numbers

To display the contents of a file, use the cat command, but if you run it without options, it will simply display the contents. To display the contents of a file with line numbers, run the cat command with the option '-n'. If you don't want to add line numbers to blank lines in the file, add the option "-b".
Directory and file operations

Create an empty file (zero bytes)

To create an empty file, use the touch command, which changes the type stamp of a file, but creates a zero-byte file if the argument is a non-existent file.
Directory and file operations

Search files for strings

Use the find command to search for files that exist in your Linux system. find <Directory name> <Option> <File name> Set each argument to a value and perform the search. The directory name is the name of the directory from which the file search will be performed. The find command searches the specified directory and all subdirectories below it.(An error will occur if you search for a directory that cannot be referenced with permissions.) option allows you to specify what files to search. For example, you can search only for directories, or only for files that belong to a certain owner.
Directory and file operations

Compressed in GZIP format, GZIP format decompression

GZIP is the most commonly used compression method for files on Linux. It is usually used to reduce the size of a file by compressing it into a single (archived) file using the tar command.
Directory and file operations

Name your files with dates etc.

Name your files with dates etc. The command to append a date to a file name is the 'date' command. ●How to use the date command $ date 2020 Septembe 23 Wednesday 00:11:21 JST ---------------------------------------------------------- The date is now displayed. Now run it as follows ---------------------------------------------------------- $ date +%Y%m%d 20200923 -------------------------
Directory and file operations

Search for and delete specific files

The find command can be used to search for and remove files that have certain things in common. The arguments are the directory to be searched, the criteria for the files to be searched, the -ok option or the -exec option, and the delete command rm.
Directory and file operations

Deleting files that cannot be normally deleted on Linux

To delete a file, run the rm command. However, files whose names begin with "-" or contain spaces or metacharacters (meta-characters) cannot be deleted because the shell cannot recognize them correctly. However, in Windows and MacOS, files and directories can be created, so if a file is shared or uploaded, a file with such a name may exist in Linux. In this case, if the name contains a hyphen "--", you can either delete the file by adding the "--" option to the rm command and specifying the file containing the hyphen as an argument, or you can prefix the file name with". /" at the beginning of the file name to delete it. Files containing spaces can be removed by enclosing the file name in quotation marks '' or double quotation marks "", or by prefixing the space with an escape sequence.
Directory and file operations

Converting image file formats on Linux

In Linux, there is an image format conversion command, convert command. The convert command is part of the "ImageMagick" package and allows you to perform a variety of image conversions with the command. To run the convert command, specify the file to be converted and the file to be converted as arguments. The file format is automatically determined by the extension included in the file name.