Uly.me

cloud engineer

  • Home
  • About
  • Archives
Home/2017/Archives for December 2017

Archives for December 2017

December 21, 2017

Empty A File

If you work with vi, nano or any other command line editor, deleting a line is a fairly easy thing to do. If the file is too large, deleting the content line by line is not fun. There’s a better way to empty a file without deleting it. Here are several ways.

$ > filename
$ truncate -s 0 filename
$ echo "" > filename

$ > filename $ truncate -s 0 filename $ echo "" > filename

Filed Under: Linux

December 21, 2017

Sudoers

The /etc/sudoers file gives users the ability to run commands that are typically reserved for administrators. The commands require a password or no password, depending on how you set them up in the sudoers file. The sudoers file can’t be edited using any text editor. You have to use visudo.

$ visudo

$ visudo

Add groups to access sudo.

# Allow users in techgroup to run all commands
%techgroup   ALL=(ALL)   NOPASSWD: ALL
# Allow users in techgroup without a password
%techgroup   ALL=(ALL)   NOPASSWD: ALL
# Allow users in techgroup to shutdown the system
%techgroup   localhost=/sbin/shutdown -h now
#includedir /etc/sudoers.d

# Allow users in techgroup to run all commands %techgroup ALL=(ALL) NOPASSWD: ALL # Allow users in techgroup without a password %techgroup ALL=(ALL) NOPASSWD: ALL # Allow users in techgroup to shutdown the system %techgroup localhost=/sbin/shutdown -h now #includedir /etc/sudoers.d

Typically you have to add your groups in the sudoers file. Notice the last line. Sudoers will include config files found under the /etc/sudoers.d directory. In certain circumstances, there are others pieces of software such as compliance software CFEngine that writes over changes in the sudoers file. If this is the case, then you have to add your groups in a file inside the /etc/sudoers.d directory.

Filed Under: Linux Tagged With: sudoers

December 21, 2017

Cron Allow

Some Linux distributions don’t turn on cron automatically for users. To give certain users access to cron, add them to cron.allow.

Edit cron.allow.

$ sudo nano /etc/cron.allow

$ sudo nano /etc/cron.allow

Add one user per line.

johndoe

johndoe

Save and close.

Filed Under: Linux Tagged With: cron

  • 1
  • 2
  • Next Page »
  • Cloud
  • Linux
  • Git

Copyright © 2012–2021