Hiển thị các bài đăng có nhãn ubuntu. Hiển thị tất cả bài đăng
Hiển thị các bài đăng có nhãn ubuntu. Hiển thị tất cả bài đăng

Thứ Tư, 27 tháng 4, 2016

Reset a lost password on an Ubuntu VM / CentOS VM

CentOS 6

    Click [View Console] to access the console and click the send CTRL+ALT+DEL button on the top right. Alternatively, you can also click [RESTART] to restart the server.
    You will see a GRUB boot prompt telling you to press any key - you have only a few seconds to press a key to stop the automated booting process. (If you miss this prompt you will need to restart the VM again)
    At the GRUB prompt, type "a" to append to the boot command.
    Add the text "single" and press enter.
    System will boot and you will see the root prompt. Type "passwd" to change the root-password and then reboot again.
Debian, Ubuntu, CentOS 7

    Click [View Console] to access the console and click the send CTRL+ALT+DEL button on the top right. Alternatively, you can also click [RESTART] to restart the server.
    As soon as the boot process starts, press ESC to bring up the GRUB boot prompt. You may need to turn the system off from the control panel and then back on to reach the GRUB boot prompt.
    You will see a GRUB boot prompt - press "e" to edit the first boot option. (If you do not see the GRUB prompt, you may need to press any key to bring it up before the machine boots)
    Find the kernel line (starts with "linux /boot/") and add init="/bin/bash" at the end of the line (On CentOS 7, the line may start with linux16).
    Press CTRL-X or F10 to boot.
    System will boot and you will see the root prompt. Type "mount -rw -o remount /" and then "passwd" to change the root password and then reboot again.

FreeBSD

The boot menu has an option to boot into single-user mode. Press the key for single user mode (2). At the root prompt, type "passwd" to change the root password and then reboot again.
CoreOS

CoreOS by default uses SSH key authentication. On Vultr, a root user and password are created. If an SSH key is selected when creating the VPS, this SSH key can be used to login as user "core".

It is possible to reset the standard root login by executing "sudo passwd" as user "core". Login as "core" using the SSH key first.

If you lost your SSH key, then you can login as the "core" user by editing the grub loader. Follow these steps:

    Click [View Console] to access the console and click the send CTRL+ALT+DEL button on the top right. Alternatively, you can also click [RESTART] to restart the server.
    You will see a GRUB boot prompt - press "e" to edit the first boot option. (If you do not see the GRUB prompt, you may need to press any key to bring it up before the machine boots)
    At the end of the line that begins with "linux$" add " coreos.autologin=tty1" (no quotes).
    Press CTRL-X or F10 to boot. You will be logged in as "core" when the system boots.
    Remember to reboot your server after you have reset your login.
Read More

Thứ Ba, 17 tháng 11, 2015

How to install configure printers on Linux

Install required packages
apt-get install cups cups-client "foomatic-db".
Add user to lpadmin group
adduser root lpadmin
Output
 Adding user `root' to group `lpadmin' ...
 Adding user root to group lpadmin
 Done.
Restart cups and samba service
service cups restart 
service samba restart
 Find USB printer
netstat -ant | grep 631 
lsusb
Configuring Printer
     Open browser and type:
    http://127.0.0.1:631/
    In semicolon: CUPS for Administrators
    Click on Adding Printers and Classes
    Click on Add printer
    Type your username(system account) and password(system password)
    Choose your printer
    Follow instructions to complete rest of the installation……
    In System Settings: Go and check
        Printers
    You’ll see your installed printer
Is the printer on Win7 shared? 
try adding it directly using one of the following URI examples:

smb://WORKGROUP_NAME/MACHINE_NAME/PrinterName
smb://MACHINE_NAME/PrinterName
smb://192.168.0.100/PrinterName
List samba shares
smbclient -L < Windows host name > -U < Windows Administrator account >

Read More

Chủ Nhật, 15 tháng 11, 2015

Start/stop iptables on Ubuntu

Iptables is a firewall, installed by default on all official Ubuntu distributions (Ubuntu, Kubuntu, Xubuntu).
Iptables is a command it's not a service, so generally it's not possible to use commands like
service iptables start
or
service iptables stop
In order to start and stop the firewall, but some distros like centos have installed a service called iptables to start and stop the firewall and a configuration file to configure it. Anyway it's possible to make a service to manage iptables editing or installing a script for this scope. All services in linux, ubuntu is not an exception, are executable scripts inside /etc/init.d folder, that implements a standard interface (start,stop,restart) A possible script looks like this:
#!/bin/sh -e
### BEGIN INIT INFO
# Provides:          iptables
# Required-Start:    mountvirtfs ifupdown $local_fs
# Default-Start:     S
# Default-Stop:      0 6
### END INIT INFO

# July 9, 2007
# James B. Crocker <ubuntu@james.crocker.name>
# Creative Commons Attribution - Share Alike 3.0 License (BY,SA)
# Script to load/unload/save iptables firewall settings.

PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"

IPTABLES=/sbin/iptables
IPTABLES_SAVE=/sbin/iptables-save
IPTABLES_RESTORE=/sbin/iptables-restore

IPTABLES_CONFIG=/etc/iptables.conf

[ -x $IPTABLES ] || exit 0

. /lib/lsb/init-functions


case "$1" in
start)
 log_action_begin_msg "Starting firewall"
        type usplash_write >/dev/null 2>/dev/null && usplash_write "TIMEOUT 120" || true
 if $IPTABLES_RESTORE < $IPTABLES_CONFIG ; then
  log_action_end_msg $?
 else
  log_action_end_msg $?
 fi
        type usplash_write >/dev/null 2>/dev/null && usplash_write "TIMEOUT 15" || true
 ;;

stop)
 log_action_begin_msg "Saving current firewall configuration"
 if $IPTABLES_SAVE > $IPTABLES_CONFIG ; then
  log_action_end_msg $?
 else
  log_action_end_msg $?
 fi
 log_action_begin_msg "Flushing ALL firewall rules from chains!"
 if $IPTABLES -F ; then
  log_action_end_msg $?
 else
  log_action_end_msg $?
 fi
 log_action_begin_msg "Deleting ALL firewall chains [Warning: ACCEPTING ALL PORT SERVICES!]"
 if $IPTABLES -X ; then
  $IPTABLES -P INPUT ACCEPT
  $IPTABLES -P FORWARD ACCEPT
  $IPTABLES -P OUTPUT ACCEPT
  log_action_end_msg $?
 else
  log_action_end_msg $?
 fi
 ;;

save)
 log_action_begin_msg "Saving current firewall configuration"
 if $IPTABLES_SAVE > $IPTABLES_CONFIG ; then
  log_action_end_msg $?
 else
  log_action_end_msg $?
 fi
 ;;

force-reload|restart)
 log_action_begin_msg "Reloading firewall configuration [Warning: POTENTIAL NETWORK INSECURITY DURING RELOAD]"
 $IPTABLES -F
 $IPTABLES -X
 if $IPTABLES_RESTORE < $IPTABLES_CONFIG ; then
  log_action_end_msg $?
 else
  log_action_end_msg $?
 fi
 ;;

*)
 echo "Usage: /etc/init.d/iptables {start|stop|save|restart|force-reload}"
 exit 1
 ;;
esac

exit 0
This script is part of this tutorial, all the commands to configure the firewall must be inserted, according to the script above, into /etc/iptables.conf file. This script must be inserted into a file called iptables in /etc/init.d and make it executable using

chmod+x *iptables*

and add the service to runlevels using

update-rc.d iptables defaults

You can add new rules from shell, these rules will be immediatly active and will be added to /etc/iptables.conf when service stops(it means them will be saved for sure when system shutdown).
Read More

Thứ Ba, 27 tháng 1, 2015

Ubuntu: How to run scripts on start up?

1>

One approach is to add an @reboot cron task:

    Running crontab -e will allow you to edit your cron.

    Adding a line like this to it:

    @reboot /path/to/script

    will execute that script once your computer boots up.


2>

How about adding the command to /etc/rc.local? you'll have to use sudo access though to edit this file.

sudo nano /etc/rc.local

Read More