業務用エアコン関連の技術情報、エラーコード、環境問題対策に関する別サイト「エアコンの安全な修理・適切なフロン回収」

nuy

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$ date2020 Septembe 23 Wednesday 00:11:21 JST----------------------------------------------------------The date is now displayed. Now run it as follows----------------------------------------------------------$ date +%Y%m%d20200923-------------------------
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.
Directory and file operations

Editing image format files on Linux

●Rotate the imageThe Linux convert command can be used to rotate images.To rotate an image, add the "-rotate" option to the convert command and specify the rotation angle as an argument.●Enlarge or reduce the imageTo scale an image file, use the convert command with the "-geometry" option. You can specify the width and height as arguments, but if you want to scale the image while keeping the aspect ratio, you can specify the ratio as "%".
Directory and file operations

Sorting files

●Sort by increasing file size.When viewing the files in a directory, they are usually displayed in alphabetical order by file name.However, it is possible to display the desired files and directories in size order.In this case, you can run the ls command with the option "-S" to display the files in order of increasing file size.The "-S" option is an uppercase S.
Directory and file operations

Various ways to view files

●Displays the number of files in a directoryThe ls command allows you to view files in the current directory or in a specific directory.It can also tell you the number of files instead of the file or directory name.In such a case, you can get the number of files by using the find command, which is a file search command, together with the wc command, which does the countingUse the find command with the directory you want to count as an option, the file type with the "-type" option, and then use the pipe "|" to count the number of lines with the wc command with the "-l" option to display the number.
Directory and file operations

File comparison

●Compare two filesTo see if there is a difference between the two files, use the "cmp" command.Specify the file you want to compare as an argument and run it.If there is a difference, it will print the byte position and line number. Also, if there is no difference, the cmp command will not display any message, only a prompt.
Directory and file operations

Extraction of strings and lines in a file

●Extract strings that start with a specific characterIf you want to extract a specific string from a long file, use the grep command.By specifying the string to be extracted and the file as the arguments of the grep command, and by adding "^" (carrot) as an additional condition to extract data starting from a specific string, you can extract data starting from that string.
Directory and file operations

File manipulation with tar command

●View the contents of the archive created by the tar commandTo view the contents of an archive created by the tar command, run the tar command with the "t" option.If you have saved the file as a file, use the "f" option together.If the "v" option is not used, only the names of the files included in the archive will be displayed; if it is used, detailed information such as the attributes of each file will be displayed.※The tar command can omit the "-" (hyphen) option specification.
Disk and device management

Check the hard disk usage.

To check the Linux hard disk information, use the "df command".The df command is used to set the hard disk'sUsed spaceFree spacePercentage of usageThe df command displays the following informationIn Linux, hard disks are treated as special files called device files.IDE drives have the names /dev/hda (primary star hard disk), /dev/hdb (primary slave hard disk), etc. on Linux systems.The results of the df command will also show the names of these files, so you can distinguish between them and check their usage even if you are using multiple hard disks.
Disk and device management

Display the partition table

Display the partition tableTo view the partition table, run ...
Disk and device management

Show the available formatting formats.

Linux supports multiple file formats, and this tends to increase with each version upgrade.So, if you want to check what file formats are supported, you can run the fdisk command with the device as an argument, and then run the interactive command "l" to display the list of supported files.