To See System Information:
who -b -shows last rebooted time
cal – Show this month's calendar
uptime – Show current uptime
w – Display current logged in users
whoami – tells ur user id
uname -a – Show kernel information
less /proc/cpuinfo – CPU information
less /proc/meminfo – Memory information
df – Show local partitions
du – Show directory space usage
date – Show the current date and time
free – Show memory and swap usage details
ls - to list the files in current directory
ls -a - to list the hedden files
less var/log/messages - to see system log messages
mail - to see mails
To get help for unkonuwn Commands
man -k keyword – Display man pages containing keyword
man command – Show the manual for command
man -t man | ps2pdf - > man.pdf – Make a pdf of a manual page
which command – Show full path name of command
time command – See how long a command takes
which <commnad> – will gives the full path of command
To Find and search:
grep <word> <filename>– Search for a word in the filename
command | grep <word> – Search for a particular word in the output of command
ex: who | grep <username>
find / -name filename – It will search for file called filename in / directory
find / -name ”*filename*” – It will search for file containing the string filename in / directory.
File Permissions
chmod 777 <filename>– read, write, execute for all
chmod 755 <filename>– rwx for owner, rx for group and world
read=4
write=2
execute=1
7=read+write+execute
For more options, see man chmod.
commands related to directory levels:
cd dir – Change directory to dir
cd – Change to home
mkdir dir – Create a directory dir
pwd – Show current directory
rm name – Remove a file or directory called name
rm -r dir – Delete a directory dir
rm -f file – remove a file forcefully
rm -rf dir – Force remove an entire directory dir and all it’s included files and subdirectories
cp file1 file2 – Copy file1 to file2
cp -r dir1 dir2 – Copy dir1 to dir2
cp file /home/dirname – Copy the file called filename to the /home/dirname directory
mv file /home/dirname – Move the file called filename to the /home/dirname directory
mv file1 file2 – Rename or move file1 to file2;
ln -s file link – Create symbolic link link to file
touch file – Create a 0kb file or update file
cat > file – Places standard input into file
cat file – Display the file called file
more file – Display the file called file one page at a time, proceed to next page using the spacebar
head file – Display first 10 lines of file
head -20 file – Display the first 20 lines of the file called file
tail file – Output the last 10 lines of file
tail -20 file – Display the last 20 lines of the file called file
tail -f file – Output the contents of file as it grows, starting with the last 10 lines
Network
ifconfig – List IP addresses for all devices on the local machine
ping host – Ping host and output results
dig domain – Get DNS information for domain
dig -x host – Reverse lookup host
nslookup <hostname>-to check IP address
netstat -ar - to see gate way and netmask
Remote Login
ssh <hostname> – To logged into to another server.
User Administration
adduser accountname – Create a new user call accountname
passwd accountname – Give accountname a new password
su – Log in as superuser from current login
exit – Stop being superuser and revert to normal user
Process Management
ps – Display your currently active processes
top – Display all running processes
kill <pid> – Kill process id pid
killall proc – Kill all processes named proc (use with extreme caution)
bg – Lists stopped or background jobs; resume a stopped job in the background
fg – Brings the most recent job to foreground
fg n – Brings job n to the foreground
Shutdown and restart
shutdown -h now – Shutdown the system now and do not reboot
halt – Stop all processes - same as above
shutdown -r 5 – Shutdown the system in 5 minutes and reboot
shutdown -r now – Shutdown the system now and reboot
reboot – Stop all processes and then reboot - same as above
startx – Start the X system
init 1 - to switch to rum level 1
No comments:
Post a Comment