A method of controlling a refrigerator, when a difference between a temperature of an inside of a freezer compartment and a set temperature is referred to as a first error temperature and when a difference between a temperature of an inside of a refrigerator compartment and the set temperature is referred to as a second error temperature, comprising: varying stroke of an inverter linear compressor to operate the inverter linear compressor by a maximum output when the first or second error temperature is higher than a maximum output temperature; and varying the stroke of the inverter linear compressor at least once in one period of a freezer or refrigerator cycle to operate the inverter linear compressor when the first or second error temperature is no more than the maximum output temperature; wherein, in varying the stroke of the inverter linear compressor at least once in one period of a freezer or refrigerator cycle to operate the inverter linear compressor when the first or second error temperature is no more than the maximum output temperature, the stroke of the inverter linear compressor varies to vary an output when the first error temperature is, in a first temperature period, higher than a first target temperature based on the first target temperature and is, in a second temperature period, lower than the first target temperature; wherein, when the first error temperature is in the first temperature period, the inverter linear compressor is operated by an output between 95% and 85% of the maximum output of the inverter linear compressor ; when the first error temperature is in the second temperature period, the inverter linear compressor is operated by an output between 84% and 75% of the maximum output of the inverter linear compressor ; and wherein, when the first error temperature is, in a further period, lower than in the second temperature period, the inverter linear compressor is operated by an output between 74% and 60% of the maximum output of the inverter linear compressor . varying stroke of an inverter linear compressor to operate the inverter linear compressor by a maximum output when the first or second error temperature is higher than a maximum output temperature; and varying the stroke of the inverter linear compressor at least once in one period of a freezer or refrigerator cycle to operate the inverter linear compressor when the first or second error temperature is no more than the maximum output temperature; wherein, in varying the stroke of the inverter linear compressor at least once in one period of a freezer or refrigerator cycle to operate the inverter linear compressor when the first or second error temperature is no more than the maximum output temperature, the stroke of the inverter linear compressor varies to vary an output when the first error temperature is, in a first temperature period, higher than a first target temperature based on the first target temperature and is, in a second temperature period, lower than the first target temperature; wherein, when the first error temperature is in the first temperature period, the inverter linear compressor is operated by an output between 95% and 85% of the maximum output of the inverter linear compressor ; when the first error temperature is in the second temperature period, the inverter linear compressor is operated by an output between 84% and 75% of the maximum output of the inverter linear compressor ; and wherein, when the first error temperature is, in a further period, lower than in the second temperature period, the inverter linear compressor is operated by an output between 74% and 60% of the maximum output of the inverter linear compressor . <EOS>