Found 2065 Articles for Operating System

Fastest way to tell if two files have the same contents in Unix/Linux

Mukul Latiyan
Updated on 29-Jul-2021 11:18:14

554 Views

Let’s say that we have two files inside a directory called dir1, and at first both these files are different. Different in the sense that the text they contain isn’t the same.The files in the folder −immukul@192 dir1 % ls -ltr total 16 -rw-r--r-- 1 immukul staff 7 Jul 7 10:37 2.txt -rw-r--r-- 1 immukul staff 8 Jul 8 19:05 3.txtThe contents inside the first file(2.txt) looks something like this −immukul@192 dir1 % cat 2.txt orangeThe contents inside the second file(2.txt) looks something like this −immukul@192 dir1 % cat 3.txt uorangeWe can easily make use of the diff command to ... Read More

Crontab day of the week syntax on Linux

Mukul Latiyan
Updated on 29-Jul-2021 11:15:29

3K+ Views

In order to understand the syntax of a crontab job, we first need to explore and understand what a crontab job is.A crontab is nothing but a list of commands that we can run during a cron job. A cron job is a utility that schedules automatic execution of commands at specific times.We can start a cron job with the help of bash script by following the commands shown below −crontab -eThis will open a file which you can edit, insert the cron job shell script in the above file and then close that file.Just insert the code shown below ... Read More

Convert XLSX to CSV in Linux with Command Line in Linux

Mukul Latiyan
Updated on 29-Jul-2021 11:13:16

1K+ Views

XLSX file is a standard file extension for the modern Microsoft Excel spreadsheet. We use of these files to analyze and organize data and they usually contain numerical data separated by rows and columns within a cell.On the other hand, a CSV file is basically a delimited text file that uses a comma to separate values, and each line of this file is usually a data record.While both the xlsx and csv formats of storing data are way different, as one makes use of tables with rows and columns, while the other uses commas to separate the values, but that ... Read More

Best practices when running Node.js with port 80 (Ubuntu) in Linux

Mukul Latiyan
Updated on 29-Jul-2021 11:10:17

559 Views

We know that most of the time we want our node applications to listen on port 80. While it is a widely used technique and many times we don’t need anything else then just simply mentioning the port as 80 in our project configurations. The real issue actually resides in the fact that many of the operating systems nowadays require root privileges for this to happen (e.g., OS X, BSD).One workaround is to make sure that we start our application with the superuser.Commandsudo node server.jsWhile this might actually solve the problem for quite an extent, this approach has its vulnerabilities ... Read More

How to add a new entry to the PATH variable in ZSH on Mac OS in Linux

Mukul Latiyan
Updated on 29-Jul-2021 11:06:32

13K+ Views

By default, we don’t have the .zshrc file present in macOS Catalina, and we need to create it. In order to create the .zshrc file, we can follow the steps shown below −Open TerminalType touch ~/.zshrc to create the file.Hit ReturnWe can also open the .zshrc file in the terminal from any directory by just typing the command shown belowExamplevi ~/.zshrcOutputimmukul@192 linux-questions-code % cat ~/.zshrc export GOPATH=/Users/immukul/go_projects export NDHOME=/Users/immukul/Downloads export GOTRACEBACK=all export GOROOT=/usr/local/go export LC_CTYPE=C export PATH=/home/Systems export LANG=CIt should be noted that the output may vary from machine to machine.To add an entry to the PATH variable present inside ... Read More

How to wrap each input line to fit in specified width in Linux?

Shilpa S
Updated on 01-Jul-2021 15:46:27

549 Views

To wraps a line in an input file to fit the specified width, we use the fold command in the Linux operating system.The fold command is used to making a file with long lines more readable on a limited width output by performing a line wrap in the Linux system. Most Linux/Unix terminals default screen width of 80, and sometimes while reading files with long lines could be annoying.The fold command wraps each input line to fit in specified width and allows the user to set the maximum length of a line. The fold command was inherited into the first ... Read More

How to split or break large files into pieces in Linux?

Shilpa S
Updated on 01-Jul-2021 15:43:19

11K+ Views

To split large files into small pieces, we use the split command in the Linux operating system.The split command is used to split or break large files into small pieces in the Linux system. By default, it generates output files of a fixed size, the default lines are 1000 and the default prefix would be ‘x’. For example, if the output file is not given, the default filename would be xaa, xab, etc. When a – (hyphen) is used instead of an input file then the data is derived from standard input.SyntaxThe general syntax of the split command as follows.split [OPTION]... ... Read More

How to sort lines of text files in Linux?

Shilpa S
Updated on 01-Jul-2021 15:41:01

14K+ Views

To sort lines of text files, we use the sort command in the Linux system.The sort command is used to prints the lines of its input or concatenation of all files listed in its argument list in sorted order. The operation of sorting is done based on one or more sort keys extracted from each line of input. By default, the entire input is taken as the sort key.SyntaxThe general syntax of the sort command is as follows.sort [OPTION]... [FILE]... sort [OPTION]... --files0-from=FBrief description of options available in the sort command.Sr.No.Option & Description1-b, --ignore-leading-blanksIgnore leading blanks.2-d, --dictionary-orderConsider only blanks and ... Read More

How to shrink or extend the size of a file in Linux?

Shilpa S
Updated on 01-Jul-2021 15:37:26

15K+ Views

The truncate command is used to shrink or extend the size of a file to the given size. The truncate command cannot remove the file whereas removes the contents of the file and set size of file is zero byte. The meaning of truncate is reducing. While reducing the size of the file is the specified size is less than actual size then extra data will be lost.SyntaxThe general syntax of the truncate command is as follows.$ truncate OPTION... FILE...Brief description of options available in the truncate command.Sr.No.Option & Description1-c, --no-createDo not create any files2-o, --io-blocksManage size as number of ... Read More

How to removes duplicate lines from a sorted file in Linux?

Shilpa S
Updated on 01-Jul-2021 15:34:36

7K+ Views

To remove duplicate lines from a sorted file and make it unique, we use the uniq command in the Linux system. The uniq command work as a kind of filter program that reports out the duplicate lines in a file. It filters adjacent matching lines from the input and gives a unique output. This command is also available in the Windows and IBM i operating system.SyntaxThe general syntax of the uniq command is as followsuniq [OPTION]... [INPUT [OUTPUT]]Brief description of options available in the fmt command.Sr.No.Option & Description1-c, --countDisplay how many times line was repeated.2-d—repeatedDisplay only repeated lines, one for ... Read More

Advertisements