≡
Difference between revisions of "Linux-Commands"
(→Process Related) |
(→File Permission Related) |
||
Line 92: | Line 92: | ||
===File Permission Related=== | ===File Permission Related=== | ||
+ | |||
+ | '''$ chmod octal file-name''' - change the permissions of file to octal , which can be found separately for user, group and world; octal value 4 -read 2 –write 1 –execute | ||
+ | '''$ chown owner-user file''' - change owner of the file | ||
+ | '''$ chown owner-user:owner-group file-name''' - change owner and group owner of the file | ||
+ | '''$ chown owner-user:owner-group directory''' - change owner and group owner of the directory | ||
===Network=== | ===Network=== |
Revision as of 09:06, 31 March 2014
Contents
System Commands
$ uname –a - display linux system information $ uname –r - display kernel release information $ uptime - show how long system running + load $ hostname - show system host name $ hostname -i - display the IP address of the host $ last reboot - show system reboot history $ date - show the current date and time $ cal - show this month calendar $ w - display who is online $ whoami - who you are logged in as $ finger user - display information about user
$ dmesg - detected hardware and boot messages $ cat /proc/cpuinfo - CPU model $ cat /proc/meminfo - hardware memory $ cat /proc/interrupts - lists the number of interrupts per CPU per I/O device $ lshw - displays information on hardware configuration of the system $ lsblk - displays block device related information in Linux $ free -m - used and free memory (-m for MB) $ lspci -tv - show PCI devices $ lsusb -tv - show USB devices $ lshal - show a list of all devices with their properties $ dmidecode - show hardware info from the BIOS $ hdparm -i /dev/sda -show info about disk sda $ hdparm -tT /dev/sda - do a read speed test on disk sda $ badblocks -s /dev/sda - test for unreadable blocks on disk sda
Statistics and Analyze
$ top - display and update the top cpu processes $ mpstat 1 - display processors related statistics $ vmstat 2 - display virtual memory statistics $ iostat 2 - display I/O statistics (2sec Intervals) $ tail -n 500 /var/log/syslog - last 10 kernel/syslog messages $ tcpdump -i eth1 - capture all packets flows on interface eth1 $ tcpdump -i eth0 'port 80' - monitor all traffic on port 80 ( HTTP ) $ lsof - list all open files belonging to all active processes $ lsof -u testuser - list files opened by specific user $ free –m - show amount of RAM $ watch df –h - watch changeable data continuously
Users
$ id - show the active user id with login and group $ last - show last logins on the system $ who - show who is logged on the system $ groupadd admin - add group "admin" (force add existing group) $ useradd -c "Joe Smith" -g admin -m joe - Create user "joe" and add to group "admin" $ userdel joe - delete user joe (force,file removal) $ adduser joe - add user "joe" $ usermod - modify user information
File Commands
$ ls –al - display all information about files / directories $ ls -alR - display all information about files / directories recursively $ pwd - show current directory path $ mkdir directory-name - create a directory $ rm file-name - delete file $ rm -r directory-name - delete directory recursively $ rm -f file-name - forcefully remove file $ rm -rf directory-name - forcefully remove directory recursively $ cp file1 file2 - copy file1 to file2 $ cp -r dir1 dir2 - copy dir1 to dir2, create dir2 if it doesn’t exist $ mv file1 file2 - move files from one place to another $ ln –s /path/to/file-name link-name - create symbolic link to file-name $ touch file - create or update file $ cat > file - place standard input into file $ more file - output the contents of file $ head file - output the first 10 lines of file $ tail file - output the last 10 lines of file $ tail -f file - output the contents of file as it grows starting with the last 10 lines $ gpg -c file - encrypt file $ gpg file.gpg - decrypt file
Process Related
$ ps - display your currently active processes $ ps aux | grep 'telnet' - find all process id related to telnet process $ pmap - memory map of process $ top - display all running processes $ kill pid - kill process with mentioned pid id $ killall proc - kill all processes named proc $ pkill processname - send signal to a process with its name $ bg - resumes suspended jobs without bringing them to foreground $ fg - brings the most recent job to foreground $ fg n - brings job n to the foreground
File Permission Related
$ chmod octal file-name - change the permissions of file to octal , which can be found separately for user, group and world; octal value 4 -read 2 –write 1 –execute $ chown owner-user file - change owner of the file $ chown owner-user:owner-group file-name - change owner and group owner of the file $ chown owner-user:owner-group directory - change owner and group owner of the directory
Network
Compression / Archives
Install Package
Search
Login (ssh and telnet)
File transfer
Disk Usage
Directory
Keyboard shortcuts
Alt+Ctrl+T - open Terminal Window
Alt+Ctrl+L - lock the screen Alt+Ctrl+Del - logoff
Alt+F4 - close current window Alt+F2 - pop up command window (for quickly running commands)
Super-W - show all windows in the current workspace Ctrl+Super+D - show desktop
Ctrl+A - select all items on list or text Ctrl+C - copy all selected items to clipboard Ctrl+X - cut all selected items to clipboard Ctrl+V or Mouse middle button click - paste all selected items to clipboard
PrintScr - takes screenshot Alt+PrintScr - takes screenshot of windows Shift+PrintScr - takes screenshot of selected window area