Recently I am reading the article of Windows-to-Linux roadmap . It is very userful and helpful.

As a programmer on Windows, senior develop in .Net world, I want to improve my self skills in much more deep level and have determined to move to Linux from Windows for years ago. After tried for many times, it seems very difficult for me to work on Linux. And the result is no result.

Now I decide to try again. And find the article very helpful, much more than the before reading.

Following is my read notes of article that may help someone who need it.

Part 1. Thinking in Linux

Key difference between Linux and Windows:

  1. Linux is built for networking not for printing
  2. The GUI is optional in Linux world and the text is the reality of Linux.
  3. Everything that can be done on the GUI can be done in console too.
  4. Linux has not file extension and all kinds of files can be marked as executable
  5. Even number of kernel is table and the odd is for experiment and development
  6. Rebooting for Linux should be avoided because it can’t solve the problem although it works on windows
  7. Commands are case sensitive in Linux.

Part 2. Console crash course

  1. Each console is a completely different session on the system and can be accessed as different users at the same time
  2. Remember that all commands and options are case sensitive. -R is different from -r, and will probably do different things. Console commands are almost always lowercase.
  3. The main trick is to remember that in Linux the forward-slash (/) is used where you are accustomed to using the back-slash (\). The back-slash is still used, but it specifies that a command should be continued on the next line. This is sometimes done for readability when typing in a particularly long command.
  4. In Linux, the command shell is a layer separated from the operating system.
  5. A script can specify the shell it wants to run by putting a shebang (#!) at the top of the file pointing to the desired shell.
  6. One compelling feature in the Linux file system is the file link. A link is a reference to a file, so that you can let files be seen in multiple locations of the file system. However, in Linux, a link can be treated as the original file. A link can be executed, edited, and accessed without having to do anything unusual. As far as other applications on the system are concerned, a link is the original file. When you make edits to a file through the link, you are editing the original. A link is not a copy. There are two kinds of links: a hard link and a symbolic link.
    1. A hard link can only reference files in the same file system. It provides a reference to the file’s physical index (also called an inode) in the file’s system. Hard links do not break when you move the original file around because they all point to the file’s physical data rather than its location in the file structure. A hard-linked file does not require the user to have access rights to the original file and does not show the location of the original, so it has some security advantages. If you delete a file that has been hard linked, the file remains until all references have been deleted as well.
    2. A symbolic link is a pointer to a file’s location in the file system. Symbolic links can span file systems and can even point to files in a remote file system. A symbolic link shows the location of the original file and requires a user to have access rights to the original file’s location in order to use the link. If the original file is deleted, all of the symbolic links become broken. They will point to a non-existent location in the file system.
    3. Both types of links can be made with the command ln <source> <target>. By default ln will make a hard link. The -s switch will make a symbolic link.

Part 3. Introduction to Webmin

  1. Webmin is a browser-based administration application written in Perl
  2. In Linux, the primary administrative user is called root. The root user has full control over all aspects of the system. The name of root should never be taken in vain.
  3. Once installed, Webmin is accessed through a special port, typically 10000, either locally or from a remote browser

Part 4.User administration

  1. Creating new users: user add, ex. useradd -c “normal user” -d /home/userid -g users -G webadm,helpdesk -s\ /bin/bash userid
  2. Changing passwords: passwd, ex. passwd userid 
  3. Delete Users: userdel, ,ex. userdel -r userid; The optional -r switch will delete the user’s home directory and all its contents in addition to the user. If the directory is to be preserved, omit the -r switch. This switch will not automatically delete all the files on the system that belong to the user, just the home directory.
  4. View user list: more /etc/passwd
  5. User record in passwd: userid:x:75000:75000::/home/userid:/bin/bash
  6. Login ID Password User ID Group ID Comment Home directory Default shell
    userid x 75000 75000 /home/userid /bin/bash
  7. User password file, /etc/shadow, which is encrypted.
  8. Creating a group: groupadd mygroup
  9. View all groups: more /etc/group
  10. Group password: /etc/gshadow
  11. Add members to group: gpasswd -a userid mygroup
  12. Remove users from a group: gpasswd -d userid mygroup
  13. Each file can have only one owner and one group.
  14. In Linux, group definitions tend to be based more on the resource access required than on business units.

Part 5.Linux logging

  1. One of the keys to success in managing any system is to know what is happening on the system. Linux offers exceptional logging, and the detail in the logs is configurable.
  2. Linux logs are in plain text, so you can search and read them without having to use special tools
  3. Linux logs are contained in the /var/log directory.There are several log files that are maintained by the system, but other services and programs may put their log files here too. Most logs are only readable by root, but that can be changed by simply changing the access rights to the file.
  4. /var/log/messages
    1. The messages log is the core system log file. It contains the boot messages when the system came up as well as other status messages as the system runs. Errors with IO, networking, and other general system errors are reported in this file. Other information, such as when someone becomes root, is listed here as well. If services are running, such as DHCP servers, you can watch the action in the messages file. /var/log/messages is generally your first place to look when you are troubleshooting.
  5. /var/log/XFree86.0.log
    1. This log shows the results of the last execution of the Xfree86 Xwindows server. If you are having problems getting the graphical mode to come up, this file will usually provide answers as to what is failing.
  6. Linux provides a command to rotate these logs so that you don’t have current log information mixed with older irrelevant data
    1. Generally logrotate runs automatically on a timed basis, but it can also be run manually. When executed, logrotate will take the current version of the log files and add a “.1” to the end of the filename. Then any other previously rotated files are sequenced with “.2,” “.3,” etc. The larger the number after a filename, the older the log is.
    2. You can configure the automatic behavior for logrotate by editing the /etc/logrotate.conf file
  7. Log tools
    1. dmesg – To get a quick view of the boot log for the last system boot, use the command dmesg. It generally puts out a lot of text, so you will generally want to pipe it through a viewer.
    2. tail – Sometimes you want to keep an eye on a log file as activity is occurring. Tail is designed to show the last few lines of a text file. By adding the -f switch, tail will continue to show new output as it occurs. ex.tail -f /var/log/messages
    3. more – Use “q” or [Ctrl]-C to stop looking at a file.
    4. less – Less is another text viewer, but it allows you to scroll through a file and search for information. Use “q” to quit viewing the file. Use “h” to get help on using less.
    5. logger – The logger command lets you send your own messages to the logging facility. Use it in scripts to provide messages about execution and errors.
  8. klogd and syslogd can control logging.
    1. klogd only deals with kernel messages. syslogd deals with other system messages, such as applications
    2. You can configure the behavior of both by editing the files /etc/syslog.conf and /etc/sysconfig/syslog.
    3. Essentially, each message generated by software provides some information to identify where the message came from and what message it is.
    4. The /etc/syslog.conf file allows you to specify what you want done with that kind of message.
    5. Remote logging is an excellent security feature. By placing your logs on a remote system, you can prevent a security breach from easily covering its tracks by altering the log files.

Part 6.Working with file systems

  1. Working with files and storage devices in Linux is different from Windows. There are files and a hierarchical directory structure, but beyond that you will need to develop a different way of thinking.
  2. There are no drive letters in Linux.
  3. In Linux, there is just one file structure. It starts with root (/) and all local file systems, all local devices, and all remote file systems are represented as subdirectories in this structure.
  4. When Linux first boots, it builds this file structure based on information in the /etc/fstab file.The structure of the hierarchy is completely configurable and can be changed on the fly.
  5. The term for adding a device to the file system is mounting. Linux will automatically mount a / (root) file system. There may also be a separate /boot file system, containing the core kernel boot files. Linux will also mount some special file systems.
  6. /proc contains a virtual representation of various aspects of the running system. There is information about IRQ settings, memory usage, loaded device drivers, network status, and much, much more. There is even a file called /proc/kcore, which is a virtual representation of all of the used system memory. Each of these files can be parsed just like a normal text or binary file. Some files can be written to change the behavior of the running kernel, without rebooting。
  7. The main benefit of such a system is that you can use simple scripting techniques to do very deep and powerful things to your running system
  8. Other file systems, such as removable media or remote file systems, will need to be manually mounted. When mounting a file system, you will need to know the correct way to reference it from Linux, and have an empty directory to use as a mount point. For removable media, Linux will probably create mount points for you during installation. In Red Hat Linux, the cdrom device is set up to mount to the directory /mnt/cdrom
  9. /etc/fstab:The association between a device and its mount point is configured in the /etc/fstab file. It can be human-edited, or maintained with an administrative tool
  10. In Linux, file systems are represented by a file-like name. All of the files in the /dev directory are special files called nodes that link to physical devices through the device driver
  11. The fdisk console command is used to create and manipulate partitions. When you execute fdisk, you must point it toward a device. To see the available devices, use the command fdisk -l
  12. File system types
    1. ext2: The standard Linux file system
    2. ext3: The standard Linux file system with journaling added
    3. vfat: Microsoft’s Fat32 file system
    4. jfs: IBM’s journaled file system
    5. reiserfs: Another popular journaled file system
  13. Journaled file systems help protect data from unexpected shutdowns. If a volume is shut down without dismounting, there may be unfinished work and files left in an in-between state.A journaled file system keeps a transaction record of each write to the disk for a period of time, such as five seconds. When the volume is not cleanly unmounted, the file system simply rolls back to the last known good state. A volume that would take twenty minutes to come back up now comes up in seconds!
  14. Formatting partitions – mkfs
  15. df – stands for “disk free.” It reports the amount of disk space used and available on mounted file systems
  16. du – stands for “disk usage.” It reports the amount of disk space used by the specified files and for each subdirectory (of directory arguments)
  17. fsck – used to check and repair file systems, equivalent to chkdsk in Windows. It will have different versions for different file system types, just like mkfs. fsck must be run on unmounted volumes, though it is rarely needed unless the file system was not cleanly unmounted

Part 7.Networking

Part 8.Backup and recovery

Part 9.Installing software