2017年6月1日 星期四

Linux Wake From Sleep Automatically

Want to put your Linux PC into sleep or hibernate mode and have it automatically wake at a specific time? You can easily do this with the rtcwake command, included by default with most Linux systems.
This can be useful if you want your computer to do something at a specific time, but don’t want it running 24/7. For example, you could put your computer to sleep at night and have it wake up before you do to perform some downloads.

Using rtcwake

The rtcwake command requires root permissions, so it must be run with sudo on Ubuntu and other Ubuntu-derived distributions. On Linux distributions that don’t use sudo, you’ll have to log in as root with the su command first.
Here’s the basic syntax of the command:
sudo rtcwake -m [type of suspend] -s [number of seconds]
For example, the following command suspends your system to disk (hibernates it) and wakes it up 60 seconds later:
sudo rtcwake -m disk -s 60

Types of Suspend

The -m switch accepts the following types of suspend:
  • standby – Standby offers little power savings, but restoring to a running system is very quick. This is the default mode if you omit the -m switch.
  • mem – Suspend to RAM. This offers significant power savings – everything is put into a low-power state, except your RAM. The contents of your memory are preserved.
  • disk – Suspend to disk. The contents of your memory are written to disk and your computer is powered off. The computer will turn on and its state will be restored when the timer completes.
  • off – Turn the computer off completely. rtcwake’s man page notes that restoring from “off” isn’t officially supported by the ACPI specification, but this works with many computers anyway.
  • no – Don’t suspend the computer immediately, just set the wakeup time. For example, you could tell your computer to wake up at 6am. After that, can put it to sleep manually at 11pm or 1am – either way, it will wake up at 6am.

Seconds vs. Specific Time

The -s option takes a number of seconds in the future. For example, -s 60 wakes your computer up in 60 seconds, while -s 3600 wakes your computer up in an hour.
The -t option allows you to wake your computer up at a specific time. This switch wants a number of seconds since the Unix epoch (00:00:00 UTC on January 1, 1970). To easily provide the correct number of seconds, combine the date command with the rtcwake command.
The -l switch tells rtcwake that the hardware clock is set to local time, while the -u switch tells rtcwake that the hardware clock (in your computer’s BIOS) is set to UTC time. Linux distributions often set your hardware clock to UTC time and translate that to your local time.
For example, to have your computer wake up at 6:30am tomorrow but not suspend immediately (assuming your hardware clock is set to local time), run the following command:
sudo rtcwake -m no -l -t $(date +%s -d ‘tomorrow 06:30’)


More Tips

Use the && operator to run a specific command after rtcwake wakes your system from sleep. For example, the following command suspends your computer to RAM, wakes it two minutes later, and then launches Firefox:
rtcwake -m mem -s 120 && firefox
Integrate the rtcwake command into a cron script to automatically wake your computer at a specific time. The -m no switch can also be useful in a cron script. For example, you could run the rtcwake -m no -s 28800 command in a cron script at 10pm every day. This would set your computer to wake up in 28800 seconds at 6:00am. However, your computer wouldn’t go to sleep immediately – you could put it to sleep at 11pm or 1am and it would still wake at 6am normally.

Caveats

  • RTC stands for real-time clock. rtcwake uses your computer’s hardware clock, which you can set in your BIOS, to determine when your computer will wake up. If you’re using an old computer with a dying CMOS battery that can’t keep the clock running properly, this won’t work.
  • If sleep, suspend to RAM, or hibernate don’t work properly with your Linux system – perhaps because Linux doesn’t have the drivers to make them work properly with your hardware – this may not work.
  • Be careful when setting a laptop to automatically wake at a specific time. You wouldn’t want it waking up, running, and overheating or running down its battery in a laptop bag.

2017年5月7日 星期日

ubuntu_16.10 BusyBox v1.22.1 Fix

BusyBox v1.22.1 (Ubuntu 1:1.22.0-15ubuntu1) built-in shell (ash)
Enter 'help' for a list of built-in commands
command : fsck /dev/sda1  # or sda2  

2016年12月14日 星期三

SUSE Install hangs on "starting udev…."

輸入:vga=791 nomodeset 

















VGA Resolution and Color Depth reference Chart:



Depth800×6001024×7681152×8641280×10241600×1200
8 bitvga=771vga=773vga=353vga=775vga=796
16 bitvga=788vga=791vga=355vga=794vga=798
24 bitvga=789vga=792vga=795vga=799

2015年10月19日 星期一

自動登入[Window]

Windows Server 2003
cmd輸入 rundll32 netplwiz,UsersRunDll 


Windows 7 - 8  - 8.1 - 10 -  2008-  2008R2 - 2012 - 2012R2
cmd輸入  netplwiz

以圖形化介面設定

首先我們先打開【執行】
clip_image001
然後輸入指令 netplwiz 或是 control userpasswords2
兩個指令執行結果都是一樣的,擇一即可
clip_image002
clip_image003
接下來在下面【這台電腦的使用者】中,選擇要自動登入的帳號,然後在將上面的【必須輸入使用者名稱和密碼,才能使用這台電腦】這個項目取消打勾,然後按下【確定】。
clip_image004
按下【確定】之後,會跳出一個【自動登入】的對話框,請輸入這個帳號的密碼。
按下確定就設定成功了。
clip_image005
接下來記得重新開機驗證看看,是否可以會自動登入。

以登錄檔方式設定

如果要採用登錄檔的方式來進行設定,同樣的請先打開【執行】
clip_image001[1]
然後輸入指令 regedit ,然後按下確定。
clip_image006
打開登錄編輯程式之後,找到以下機碼:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
clip_image007
然後在右邊的窗格中,找到下面兩個名稱,並予以修改
找到 [AutoAdminLogon] ,然後將值修改為 1
找到 [DefaultUserName] ,然後將值修改為要自動登入的使用者帳號,如果是網域帳號,別忘了要使用 網域\帳號 這樣的格式。
clip_image008
接下來在右邊窗格的空白處按右鍵,選擇新增一個字串值。
clip_image009
然後將名稱設定為 [DefaultPassword] ,然後將值設定為上述 [DefaultUserName] 使用者帳號所對應的密碼。
clip_image010
這樣就設定完畢了,接下來就是重新開機驗證看看是否會自動登入。

不過您有沒有發現,如果您是使用登錄檔的方式來設定自動登入的話,密碼將會以明文的方式存在登錄檔當中。要是有心人借用您的電腦,那他很可能就會在這邊得知您的常用密碼。
但是以圖形化介面來設定自動登入的話,您的密碼並不會以明文的方式被存在 DefaultPassword 中,所以相對比起來會較安全一點。

設定登入後如何在開機後登入另一個帳號

如果您已經設定了自動登入,如果在某天想要自己手動登入為另一個帳號,那又該怎麼辦呢?
要先讓他自動登入以後再登出嗎? 這樣實在很慢。還是先把設定全都取消,用完再重新設定回來? 這樣好像更複雜。
其實您可以在進入 Windows 之後,但是尚未自動登入之前,先按住鍵盤上的【Shift】,那麼他就會暫時先略過本次的自動登入作業,讓您可以手動輸入另外的帳號密碼登入。完全不需修改任何設定,等到下次開機,他還是會自動登入。