+ Reply to Thread
Results 1 to 12 of 12




  

Thread: Linux commands you can use via SSH

      
  1. #1
    Will Work For Coffee :-} Big Dan has a reputation beyond reputeBig Dan has a reputation beyond reputeBig Dan has a reputation beyond reputeBig Dan has a reputation beyond reputeBig Dan has a reputation beyond reputeBig Dan has a reputation beyond reputeBig Dan has a reputation beyond reputeBig Dan has a reputation beyond reputeBig Dan has a reputation beyond reputeBig Dan has a reputation beyond reputeBig Dan has a reputation beyond repute Big Dan's Avatar
    Join Date
    October 14, 2006
    Location
    New York
    Posts
    1,954
    Rep Power
    8
    Feedback Score
    0

    Exclamation Linux commands you can use via SSH

    Just to post a few commands that you can use that may help some of you. I will better organize them when I can.

    Apache Start
    /etc/init.d/httpd stop
    /etc/init.d/httpd start
    /etc/init.d/httpd restart

    APF Firewall
    /usr/local/sbin/apf -r
    nano /etc/apf/allow_hosts.rules
    nano /etc/apf/deny_hosts.rules
    nano /etc/apf/conf.apf
    nano /etc/apf/ad/conf.antidos
    /usr/local/sbin/apf -f
    /etc/apf -d

    Backup Linux TMP Files
    cp -Rp /tmp /tmp_backup

    Backup using cPanel
    /scripts/cpbackup

    Relace blackhole and aliases
    replace :blackhole: :fail: -- /etc/valiases/*
    replace '/dev/null' ':fail:' -- /etc/valiases/*

    Broadcast Message
    wall [message]

    CGI Fix
    In order to CGI's work properly on your server for any account, you will have to add an entry as ScriptAlias under those accounts. Add in /usr/local/apache/conf/httpd.conf

    Change server password
    /root/.my.cnf

    Check Drives
    df -h

    Check Messages
    grep -i memory /var/log/messages

    Hostname
    /etc/sysconfig/network

    Check Open Ports

    nmap -sT -O localhost

    Chown
    chown -R username:username /home/username/public_html/directory/

    Ports
    /etc/services

    cPanel restart
    /etc/init.d/cpanel restart

    SSH MySQL command for adding data
    mysql -u petfel -p petfel_nuke < /home/petfel/public_html/petfel_nuke.sql

    ****petfel is the username example nuke.sql is the name of the example database. Make sure you upload your sql to your public_html directory. Keep all in one line.

    DDOS Check
    netstat -anp |grep 'tcp\|udp' | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n

    Dictionary Attack

    grep "dictionary attack" /var/log/exim_mainlog

    Find Large files
    find /home -size +100000k

    Disable Root Logins
    /etc/ssh/sshd_config

    Force cPanel Update
    /scripts/upcp --force

    Find Pid
    /usr/sbin/lsof | grep add Pid number here

    Kill Pid
    kill -9 add pid number here

    Locate large logs
    /scripts/biglogcheck -v

    Locate cPanel Users
    /var/cpanel/users

    More Commands in Finding Domains & Users
    /var/named/
    /etc/named.conf
    /usr/local/apache/conf/httpd.conf
    /etc/localdomains
    /etc/userdomains
    /etc/valiases/
    /etc/vdomainaliases

    Locate User Cron Jobs
    cd /var/spool/cron

    Locate User Aliases
    /etc/valiases/

    Rotate Logs
    /usr/sbin/logrotate -vf /etc/logrotate.conf

    Lsof TMP
    lsof | grep /tmp

    Mail Logs
    /var/log/maillog

    Optimize all MySQL Databases On The Server
    mysqlcheck -o -u root -p --all-databases

    Show Process
    ps axuf

    Shutdown Fix Now
    /sbin/shutdown -rF now

    Start Name and fix name

    /scripts/fixndc
    /etc/init.d/named stop
    /etc/init.d/named start

    Restart Cron
    service crond restart

    Tail error messages
    tail -f /var/log/messages

    Tar Command
    tar -xvzf

    Who has been on the server
    who /var/log/wtmp

    Find out what is happening on your server
    /usr/bin/w
    /usr/bin/top

    Find out who is logged on - Make sure this is blocked at the firewall!!
    /usr/bin/finger

    Find out information about your server
    /bin/uname -a
    /sbin/ipconfig

    List contents of a directory
    /bin/ls
    /bin/ls -a list all files including hidden
    /bin/ls -l list files showing their attributes
    /bin/ls -lla list all files showing their attribute

    L (list)
    mv (move)
    cd (change directory)

    uptime - How long since you're last reboot


    For Red Hat and CentOS:

    service httpd stop
    service httpd start
    service httpd restart

    Also to copy

    cp srcdirectory destinationdirectory
    Last edited by Big Dan; Nov 20th, 2007 at 12:05 pm. Reason: Added
    Big Dan
    DJ Talk - Where DJ's meet! | Almost Geek - Geeky Tutorials and Stuff | Got Email Questions?

  2. #2
    minus19
    Forum Guest

    Default

    Cheers, for that. I've been using unix for about two years now and I never find time to look up all the commands.

  3. #3
    Grand Masters grim has a reputation beyond reputegrim has a reputation beyond reputegrim has a reputation beyond reputegrim has a reputation beyond reputegrim has a reputation beyond reputegrim has a reputation beyond reputegrim has a reputation beyond reputegrim has a reputation beyond reputegrim has a reputation beyond reputegrim has a reputation beyond reputegrim has a reputation beyond repute grim's Avatar
    Join Date
    September 22, 2006
    Posts
    10,060
    Rep Power
    25
    Feedback Score
    0

    Default

    Quote Originally Posted by minus19 View Post
    Cheers, for that. I've been using unix for about two years now and I never find time to look up all the commands.
    I look most of them up as I need to

  4. #4
    Will Work For Coffee :-} Big Dan has a reputation beyond reputeBig Dan has a reputation beyond reputeBig Dan has a reputation beyond reputeBig Dan has a reputation beyond reputeBig Dan has a reputation beyond reputeBig Dan has a reputation beyond reputeBig Dan has a reputation beyond reputeBig Dan has a reputation beyond reputeBig Dan has a reputation beyond reputeBig Dan has a reputation beyond reputeBig Dan has a reputation beyond repute Big Dan's Avatar
    Join Date
    October 14, 2006
    Location
    New York
    Posts
    1,954
    Rep Power
    8
    Feedback Score
    0

    Default

    Me too
    Big Dan
    DJ Talk - Where DJ's meet! | Almost Geek - Geeky Tutorials and Stuff | Got Email Questions?

  5. #5
    minus19
    Forum Guest

    Default

    I use WinSCP more than just SecureCRT/Putty

    It's SFTP with a command line, what's really good is you can enter custom commands though and then just right click in the SFTP interace to run them on the file.

    It's free too.

  6. #6
    The Force is Strong! JuggernautH is a jewel in the roughJuggernautH is a jewel in the roughJuggernautH is a jewel in the roughJuggernautH is a jewel in the roughJuggernautH is a jewel in the rough JuggernautH's Avatar
    Join Date
    March 12, 2007
    Location
    Sweden
    Posts
    585
    Rep Power
    6
    Feedback Score
    0

    Default

    Thanks Dan

  7. #7
    Grand Masters grim has a reputation beyond reputegrim has a reputation beyond reputegrim has a reputation beyond reputegrim has a reputation beyond reputegrim has a reputation beyond reputegrim has a reputation beyond reputegrim has a reputation beyond reputegrim has a reputation beyond reputegrim has a reputation beyond reputegrim has a reputation beyond reputegrim has a reputation beyond repute grim's Avatar
    Join Date
    September 22, 2006
    Posts
    10,060
    Rep Power
    25
    Feedback Score
    0

    Default

    Quote Originally Posted by minus19 View Post
    I use WinSCP more than just SecureCRT/Putty

    It's SFTP with a command line, what's really good is you can enter custom commands though and then just right click in the SFTP interace to run them on the file.

    It's free too.
    It's what I use as well, with putty of course.

  8. #8
    Will Work For Coffee :-} Big Dan has a reputation beyond reputeBig Dan has a reputation beyond reputeBig Dan has a reputation beyond reputeBig Dan has a reputation beyond reputeBig Dan has a reputation beyond reputeBig Dan has a reputation beyond reputeBig Dan has a reputation beyond reputeBig Dan has a reputation beyond reputeBig Dan has a reputation beyond reputeBig Dan has a reputation beyond reputeBig Dan has a reputation beyond repute Big Dan's Avatar
    Join Date
    October 14, 2006
    Location
    New York
    Posts
    1,954
    Rep Power
    8
    Feedback Score
    0

    Default

    Grim stopping being a sissy and install Linux.. you can ssh right from terminal. :P
    Big Dan
    DJ Talk - Where DJ's meet! | Almost Geek - Geeky Tutorials and Stuff | Got Email Questions?

  9. #9
    Grand Masters grim has a reputation beyond reputegrim has a reputation beyond reputegrim has a reputation beyond reputegrim has a reputation beyond reputegrim has a reputation beyond reputegrim has a reputation beyond reputegrim has a reputation beyond reputegrim has a reputation beyond reputegrim has a reputation beyond reputegrim has a reputation beyond reputegrim has a reputation beyond repute grim's Avatar
    Join Date
    September 22, 2006
    Posts
    10,060
    Rep Power
    25
    Feedback Score
    0

    Default

    Quote Originally Posted by Big Dan View Post
    Grim stopping being a sissy and install Linux.. you can ssh right from terminal. :P
    Maybe next network rebuild

  10. #10
    minus19
    Forum Guest

    Default

    Quote Originally Posted by Big Dan View Post
    Grim stopping being a sissy and install Linux.. you can ssh right from terminal. :P
    How can I use the wonderfull 'windows media player' in linux though? :P

    You should check out Solaris, they send you a free disc if you ask nice

  11. #11
    Jedi Master Cyberbite is a jewel in the roughCyberbite is a jewel in the roughCyberbite is a jewel in the roughCyberbite is a jewel in the roughCyberbite is a jewel in the roughCyberbite is a jewel in the rough Cyberbite's Avatar
    Join Date
    October 8, 2007
    Location
    Quincy, MA
    Posts
    362
    Rep Power
    5
    Feedback Score
    0

    Default

    Just a word of caution to all, these are for RedHat/CentOS or any other RH based distro and some of the commands are specific to WHM/CPanel. Other distro's may put files in different places.

    Quote Originally Posted by Big Dan View Post
    Change server password
    /root/.my.cnf
    No, this holds the user's mysql username and password and default mysql hostname and database so you don't need to type

    mysql -h servername.mydomains.com -u username -p databasename

    If you want to change your user's shell password, you need to use passwd. If you want to change their mysql password it's more complicated, use CPanel's interface or phpMyAdmin.

    Quote Originally Posted by Big Dan View Post
    Check Drives
    df -h
    Sort of, it shows the drives and where they are mapped and how much drive space is on the drives and what's used and available. To check the drives you should unmount them and run a fsck on them. If you don't know what you're doing, you should use the other hint "shutdown -rF now" and it will do a check on reboot.

    Quote Originally Posted by Big Dan View Post
    Ports
    /etc/services
    This is a list of commonly used ports, not necessarily what's running on your system. To get a list of active open ports on your server one way is to run

    netstat -lpn

    but there are tons of other ways.

    Quote Originally Posted by Big Dan View Post
    Optimize all MySQL Databases On The Server
    mysqlcheck -o -u root -p --all-databases
    Be very careful about running this command on a live mysql server, it will force a lock of tables that can make reading the database impossible till the check has finished.

    Quote Originally Posted by Big Dan View Post
    Shutdown Fix Now
    /sbin/shutdown -rF now
    Be very careful about using the shutdown command, I have seen too many people typing too quickly hit [ENTER] before finishing the command then the server just does a shutdown on them and not a reboot. If you need to do a reboot, use the reboot command instead.

    Quote Originally Posted by Big Dan View Post
    Tar Command
    tar -xvzf
    you need a bit more than that.

    To compress
    tar cvzf filename.tar.gz files-to-gzip /path/to/gzip

    To uncompress
    tar xvzf filename.tar.gz

    Quote Originally Posted by Big Dan View Post
    Find out information about your server
    /bin/uname -a
    /sbin/ipconfig
    In the Linux/*nix/OSX world the command is ifconfig, not ipconfig. Microsoft is the only company who uses ipconfig.

    Quote Originally Posted by minus19 View Post
    I use WinSCP more than just SecureCRT/Putty

    It's SFTP with a command line, what's really good is you can enter custom commands though and then just right click in the SFTP interace to run them on the file.

    It's free too.
    Just to clarify, yes you can do some things through WinSCP. But that's not what it's meant for and the formatting is really bad. A general rule of thumb is for file copy (SFTP/SCP) use an SFTP/SCP client like WinSCP. For entering commands, use an SSH client like Putty/SecureCRT/Cygwin, etc.

    If anyone needs any Linux/*nix help, I've been working as a system admin/engineer for over 13 years.

    Cyberbite added 2 Minutes and 23 Seconds later...

    Quote Originally Posted by minus19 View Post
    How can I use the wonderfull 'windows media player' in linux though? :P

    You should check out Solaris, they send you a free disc if you ask nice
    WMP is far from wonderful, but there are tons of other players that will play Windows Media files, both audio and video. Depending on the distro you're running it is different steps to get it working.
    Last edited by Cyberbite; Feb 2nd, 2008 at 4:24 pm. Reason: Automerged Doublepost
    BeanTown Host- Web Hosting, Dedicated Servers, Boston Colocation and Domain Names
    CPanel,RVSkins,Fantastico,RVSiteBuilder on all accounts.
    SysAdmin Valley - a sysadmin's ramblings, tips and tricks
    Cisco Sphere - Forum for Cisco users

  12. #12
    minus19
    Forum Guest

    Default

    Quote Originally Posted by Cyberbite View Post

    WMP is far from wonderful, but there are tons of other players that will play Windows Media files, both audio and video. Depending on the distro you're running it is different steps to get it working.
    Sorry, I was being sarcastic, i'll stop it now.

    I use VLC.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Is it possible to run ASP under LINUX
    By hostcp in forum Web Hosting
    Replies: 9
    Last Post: May 16th, 2008, 9:50 am
  2. Any linux users here?
    By WeedGrinch in forum Computers and Electronics
    Replies: 20
    Last Post: Mar 8th, 2008, 1:40 am
  3. Unix or Linux
    By gedan in forum Dedicated / VPS Hosting
    Replies: 11
    Last Post: Feb 19th, 2008, 5:00 am
  4. Linux version
    By gkd in forum Computers and Electronics
    Replies: 13
    Last Post: Jan 27th, 2008, 6:23 am

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
WebTalkForums
WebTalkForums
Recent Forum Threads